|
Customer File - VSAM, KSDS Import CSV, Convert to Fixed Field |
![]() |
| The SimoTime Home Page |
This suite of sample programs describes how to import data into the Customer Master File. The numeric fields will be converted (from a text format to a Packed-Decimal or Binary format) the text fields will be passed with trailing spaces to match the defined fixed field length. The newly constructed record will be written to a VSAM, KSDS.
The import of data by fields within the record and the reformatting of the output records is actually accomplished with two COBOL programs. The first program does the File I/O of reading a sequential file and writing reformatted records to a Customer Master File. The File I/O program calls the second program to do the record formatting that reformats or converts the numeric fields and append space characters to the text fields. The COBOL programs were generated using SimoTime technology.
We have made a significant effort to ensure the documents and software technologies are correct and accurate. We reserve the right to make changes without notice at any time. The function delivered in this version is based upon the enhancement requests from a specific group of users. The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources.
Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved
This test case will be importing data from asequential file. The imported data will be converted and written to a VSAM, KSDS. The import/convert process will do a file format and a record content conversion. The following is a list of the abbreviations used when referring to the various file types and record structures.
The following table is a list of terms or abbreviations used within this document.
| Abbreviation | Description |
| CSV | Comma Separated Values - refers to a record structure that contains a group of concatenated data fields or text strings. The fields are separated or delimited by a comma. |
| FFL | Fixed Field Length - refers to a record structure that contains a group of concatenated data fields. Each field may contain text or binary data. Numeric values may be structured in a varielty of formats that include Binary, Packed-decimal or Zoned decimal. There are no field separator or field delimiter characters between the fields. |
| KSDS | Keyed Sequential Data Set - This is a type of VSAM (Virtual Sequential Access Method) data set. Records are in collating sequence by a key field and alternate indexes are allowed. Note: If the key field is alpha-numeric the collating sequence will be different between the EBCDIC-encoded and ASCII-encoded environments. For additional information about VSAM refer to an internet reference at http://www.simotime.com/indexsam.htm or a local reference at indexsam.htm |
| LSEQ | Line Sequential files are ASCII/Text files. Depending on how the file is created it may have fixed or variable length records. The separation of the individual records is maintained by the use of delimiter bytes between the records. For Windows this is usually a two byte value consisting of a Carriage-Return and Line-Feed (or CRLF), the hexadecimal notation is x'0D' and x'0A'. For UNIX systems this is usually a one byte value consisting of a Line-Feed (or LF), the hexadecimal notation is x'0A'. The record content for Line Sequential files should be display or print text using the ASCII encoding format. Hence the name ASCII/Text files. These files should not contain packed or binary data strings. |
| RSEQ | A Record Sequential file may contain fixed-length records or variable-length records. The record sequential files with fixed-length records are a series of concatenated records or data strings of a predefined length without record separator values between each record. The first byte of the first record starts at the first byte of the file. A record sequential file with variable-length records is a series of concatenated records or data strings of varying lengths without record separator values between each record. Each record is preceded by a record descriptor word (RDW) that defines the length of the record that follows. A Micro Focus header record is placed at the start of the file when the file is created. |
| VSAM | Virtual Sequential Access Method - A data access method used with IBM Mainframes running MVS, OS/390, z/OS and VSE/ESA operating systems. VSAM has been in use for over 30 years. The original VSAM had a 4-gigabyte limit for the size of data sets. IBM has enhanced VSAM to support record-level sharing and file sizes larger than 4 gigabytes. The current architectural limit varies according to the size of the data control intervals (CI's). For a 512-byte CI size, the maximum size is 2 terabytes; for a KSDS with a CI size of 32 kilobytes, the maximum size is 128 terabytes. For additional information about VSAM refer to an internet reference at http://www.simotime.com/indexsam.htm or a local reference at indexsam.htm |
When running this job on a Mainframe System the output file will be an EBCDIC-encoded, record-sequential file. The records will be concatenated fields of text strings separated (or delimited) by a comma. This file may be downloaded from the mainframe to a Windows system using FTP in ASCII mode. Since the output file is all text it will be properly converted from EBCDIC to ASCII during the file transfer (FTP) process. It will also be converted from a Record-Sequential file to a Line-Sequential file (Micro Focus terminology for ASCII/Text File). The file is now ready to import into an Excel spreadsheet, an Access Data Base or other SQL Data Bases.
When running the job on a Windows System with Micro Focus and using EBCDIC encoding the output file will be an EBCDIC-encoded, record-sequential file. The records will be concatenated fields of text strings separated (or delimited) by a comma. Since we no longer use the FTP process to transfer the file we no longer have the benefit of the FTP process doing the file-format and record-content conversion. Therefore, we need an alternative method for doing the file format conversion from record-sequential to line-sequential and the record content conversion from EBCDIC to ASCII. Refer to the File-Format and Record-Content Conversion Program for more information.
When running the job on a Windows System with Micro Focus and using ASCII encoding the output file will be an ASCII-encoded, record-sequential file. The records will be concatenated fields of text strings separated (or delimited) by a comma. Since we no longer use the FTP process to transfer the file and we no longer have the benefit of the FTP process doing the file-format conversion (since we are running in an ASCII-encoded configuration the file-content conversion is not a requirement). Therefore, we need an alternative method for doing the file format conversion from record-sequential to line-sequential. Refer to the File-Format Conversion Program for more information.
A job script may be defined as a text file containing job setup information followed by job steps that identify programs to be executed along with parameters unique to the job step. A job script may be created using a text editor. The naming of a job script is determined by the Operating System. A simple job script may contain a single job step that performs a single function. A typical job script will contain multiple job steps executed in a predefined sequence. The status of each job step may be tested at the end of each job step.
This document provides a brief overview of the Micro Focus File Formats available on Linux, UNIX or Windows Systems supported by Micro Focus.
JCL Members are batch processing scripts that are intended to run on a Mainframe-Oriented System. The term Mainframe-Oriented refers to an actual IBM Mainframe, a Windows System with Micro Focus Mainframe Express or a Micro Focus Enterprise Server with the Mainframe Transaction Option and the Batch Facility.
The following (CUEXTJ01.jcl) is a listing of the JCL member needed to run this job in a Mainframe-Oriented environment.
//CUSEXTJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CUSEXTJ1.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Read Customer Master File, write to a sequential file //* Author - SimoTime Technologies //* Date - January 01, 1989 //* //* This set of programs will run on a mainframe under MVS or on //* a Personal Computer running Windows and Mainframe Express by //* Micro Focus. //* //* ************ ************ //* * Entry * * Entry * //* * MVS * * Windows * //* ************ ************ //* * * //* ************ ************ //* * CUSEXTJ1 * * CUSEXTE1 * //* ********jcl* ********cmd* //* * * //* ************ * //* * IEFBR14 * * //* ********utl* * //* * * //* ********************************* //* * //* * //* ************ ************ ************ //* * CUSTMAST *----* CUSEXTC1 *----* CUSEXTSV * //* ************ ********cbl* ********dat* //* * * //* * * //* * *---CALL----* //* * * //* * * //* * ************ //* * * CUSEXTR1 * //* * ********cbl* //* * //* ************ //* * EOJ * //* ************ //* //* ******************************************************************* //* Step 1 of 2, This job step will delete a previously created file. //* //DELTSEQ1 EXEC PGM=IEFBR14 //CUSTRCSV DD DSN=SIMOTIME.DATA.CUSTPHON,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=256,DSORG=PS) //* ******************************************************************* //* Step 2 of 2, Execute the Sample program. //* Read the customer file (KSDS) and write a record of //* selected fields to a sequential file. Truncate spaces //* from each field and separate the fields by a comma. //* //CBLEXTS1 EXEC PGM=CUSEXTC1 //STEPLIB DD DSN=MFI01.SIMOPROD.LOADLIB1,DISP=SHR //CUSTMAST DD DSN=SIMOTIME.DATA.CUSTMAST,DISP=SHR //CUSTRCSV DD DSN=SIMOTIME.DATA.CUSTPHON,DISP=(NEW,CATLG,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=256,DSORG=PS) //SYSOUT DD SYSOUT=* //*
Windows CMD Files are batch processing scripts that are intended to run on a Windows System. The job scripts may be executed from a Windows Command line or from Windows Explorer.
The following (CUSIMPW1.cmd) is a listing of the CMD member needed to run this job. This job will do a file format conversion from a Line1 Sequential file to a VSAM, KSDS. The programs will do a record content conversion from a CSV record format with variable length fields to a record structure that uses a fixed-field length with packed data.
@echo OFF
set CmdName=CUSIMPW1
rem * *******************************************************************
rem * Job Script - a Windows Command File *
rem * This test case is provided by SimoTime Technologies *
rem * (C) Copyright 1987-2019 All Rights Reserved *
rem * Web Site URL: http://www.simotime.com *
rem * e-mail: helpdesk@simotime.com *
rem * *******************************************************************
rem *
rem * Text - Read a sequential CSV file, write to a Customer Master.
rem * Author - SimoTime Technologies
rem * Date - January 24, 1996
rem *
rem * The job will read a record sequential (RSEQ) file that will
rem * contain all text data with the fields separated by a comma and
rem * write to a Customer Master File (KSDS).
rem *
rem * Numeric fields that are defined as packed or binary will be
rem * converted.
rem *
rem * For this test case both files are ASCII encoded.
rem *
rem *
rem * ************
rem * * CUSEXTW1 *
rem * ********cmd*
rem * *
rem * *
rem * ************
rem * * run *****************************
rem * *******mifo* *
rem * * *
rem * * *
rem * * *
rem * * ************ ************ ************
rem * * * CUSTRCSV ******* CUSIMPC1 ******* CUSTMAST *
rem * * *******rseq* ********cbl* *******ksds*
rem * * *
rem * * ************
rem * * * CUSIMPR1 *
rem * * ********cbl*
rem * *
rem * ************
rem * * EOJ *
rem * ************
rem *
rem * *******************************************************************
rem * Step 1 of 3, Set Environment Variables for File Names,
rem * Delete any previously created file...
rem *
call ..\ENV1BASE %CmdName%
rem *
call SimoNOTE "*******************************************************%CmdName%"
call SimoNOTE "Starting JobName %CmdName%, User is %USERNAME%"
rem *
call SimoNOTE "Job_Step 1 of 3, Preparing the System and Job environment"
set JobStatus=0
set SYSOUT=%BaseLib1%\LOGS\SYSOUT_%CmdName%.txt
set CUSTRCSV=%BaseLib1%\DATA\Wrk1\SIMOTIME.DATA.CUSTRCSV.DAT
set CUSTMAST=%BaseLib1%\DATA\WRK1\SIMOCONV.KSDSRCSV.CUSTMAST.DAT
if exist %CUSTMAST% del %CUSTMAST%
rem *
rem * *******************************************************************
call SimoNOTE "Job_Step 2 of 3, Import Customer Info, create a new KSDS file"
call SimoNOTE "DataTake RSA CUSTRCSV=%CUSTRCSV% "
call SimoNOTE "DataMake KSA CUSTMAST=%CUSTMAST% "
run CUSIMPC1
if not "%ERRORLEVEL%" == "0" set JobStatus=10
if not "%JobStatus%" == "0" goto EOJTAG
if not exist %CUSTMAST% set JobStatus=0020
if not "%JobStatus%" == "0000" goto EOJTAG
rem *
rem * *******************************************************************
:EOJTAG
call SimoNOTE "Job_Step 3 of 3, End of Job processing"
if not "%JobStatus%" == "0" goto EOJNOK
:EOJAOK
call SimoNOTE "Finished JobName %CmdName%, Job Status is %JobStatus% "
goto :EOJEND
:EOJNOK
call SimoNOTE "ABENDING JobName %CmdName%, Job Status is %JobStatus% "
:EOJEND
call SimoNOTE "Conclude SYSOUT is %SYSOUT%"
if not "%1" == "nopause" pause
The following (CUSIMPW5.cmd) is a listing of the CMD member needed to run this job. This job will do a file format conversion from a Line Sequential file to a VSAM, KSDS. The programs will do a record content conversion from a CSV record format with variable length fields to a record structure that uses a fixed-field length with packed data.
@echo OFF
set CmdName=CUSIMPW5
rem * *******************************************************************
rem * Job Script - a Windows Command File *
rem * This test case is provided by SimoTime Technologies *
rem * (C) Copyright 1987-2019 All Rights Reserved *
rem * Web Site URL: http://www.simotime.com *
rem * e-mail: helpdesk@simotime.com *
rem * *******************************************************************
rem *
rem * Text - Read a sequential CSV file, write to a Customer Master.
rem * Author - SimoTime Technologies
rem * Date - January 24, 1996
rem *
rem * The job will read a line sequential (LSEQ) file that will
rem * contain all text data with the fields separated by a comma and
rem * write to a Customer Master File (KSDS).
rem *
rem * Numeric fields that are defined as packed or binary will be
rem * converted.
rem *
rem * For this test case both files are ASCII encoded.
rem *
rem *
rem * ************
rem * * CUSIMPW5 *
rem * ********cmd*
rem * *
rem * *
rem * ************
rem * * run *****************************
rem * *******mifo* *
rem * * *
rem * * *
rem * * *
rem * * ************ ************ ************
rem * * * CUSTLCSV ******* CUSIMPC5 ******* CUSTMAST *
rem * * *******lseq* ********cbl* *******ksds*
rem * * *
rem * * ************
rem * * * CUSIMPR5 *
rem * * ********cbl*
rem * *
rem * ************
rem * * EOJ *
rem * ************
rem *
rem * *******************************************************************
rem * Step 1 of 3, Set Environment Variables for File Names,
rem * Delete any previously created file...
rem *
call ..\ENV1BASE %CmdName%
rem *
call SimoNOTE "*******************************************************%CmdName%"
call SimoNOTE "Starting JobName %CmdName%, User is %USERNAME%"
rem *
call SimoNOTE "Job_Step 1 of 3, Preparing the System and Job environment"
set JobStatus=0
set SYSOUT=%BaseLib1%\LOGS\SYSOUT_%CmdName%.txt
set CUSTLCSV=%BaseLib1%\DATA\Wrk1\SIMOTIME.DATA.CUSTLCSV.csv
set CUSTMAST=%BaseLib1%\DATA\WRK1\SIMOCONV.KSDSLCSV.CUSTMAST.DAT
if exist %CUSTMAST% del %CUSTMAST%
rem *
rem * *******************************************************************
call SimoNOTE "Job_Step 2 of 3, Import Customer Info, create a new KSDS file"
call SimoNOTE "DataTake LSA CUSTLCSV=%CUSTLCSV% "
call SimoNOTE "DataMake KSA CUSTMAST=%CUSTMAST% "
run CUSIMPC5
if not "%ERRORLEVEL%" == "0" set JobStatus=10
if not "%JobStatus%" == "0" goto EOJTAG
if not exist %CUSTMAST% set JobStatus=0020
if not "%JobStatus%" == "0000" goto EOJTAG
rem *
rem * *******************************************************************
:EOJTAG
call SimoNOTE "Job_Step 3 of 3, End of Job processing"
if not "%JobStatus%" == "0" goto EOJNOK
:EOJAOK
call SimoNOTE "Finished JobName %CmdName%, Job Status is %JobStatus% "
goto :EOJEND
:EOJNOK
call SimoNOTE "ABENDING JobName %CmdName%, Job Status is %JobStatus% "
:EOJEND
call SimoNOTE "Conclude SYSOUT is %SYSOUT%"
if not "%1" == "nopause" pause
The following describes the COBOL Members included with this Test Case. The programs were compiled and tested on the following systems.
| 1. | An IBM Mainframe System. |
| 1.1. | Operating System is ZOS. |
| 1.2. | COBOL Compiler is IBM Enterprise COBOL. |
| 1.3. | JCL Members were used for the Job Scripting. |
| 2. | A Microsoft Windows System with Micro Focus COBOL. |
| 2.1. | Operating System is Windows/7. |
| 2.2. | COBOL Compiler is Micro Focus Enterprise Developer. |
| 2.3. | CMD Files were used for the Job Scripting. |
| 3. | A Linux System with GnuCOBOL. |
| 3.1. | Operating System is Ubuntu with GnuCOBOL. |
| 3.2. | COBOL Compiler is GnuCOBOL. |
| 3.3. | Bash Members were used for the Job Scripting. |
Note: The COBOL Source Code was generated on a Windows System using SimoTime Technologies. It was copied to other systems then compiled and executed. The same source code was used on each system.
The following (CUSIMPC1.cbl) is the COBOL I/O program that was generated with SimoTime technology. The program was tested using Micro Focus Enterprise Server on Windows/XP. The program was successfully executed in both an EBCDIC and ASCII encoded configuration.
IDENTIFICATION DIVISION.
PROGRAM-ID. CUSIMPC1.
AUTHOR. SIMOTIME TECHNOLOGIES.
*****************************************************************
* This program was generated by SimoZAPS *
* A product of SimoTime Technologies *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* *
* Generation Date: 2019-08-30 Generation Time: 01:21:20:42 *
* *
* Record Record Key *
* Function Name Organization Format Max-Min Pos-Len *
* PRIMARY CUSTRCSV SEQUENTIAL FIXED 00256 *
* *
* SECONDARY CUSTMAST INDEXED VARIABLE 00512 00001 *
* 00012 *
* *
*****************************************************************
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CUSTRCSV-FILE ASSIGN TO CUSTRCSV
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS CUSTRCSV-STATUS.
SELECT CUSTMAST-FILE ASSIGN TO CUSTMAST
ORGANIZATION IS INDEXED
ACCESS MODE IS SEQUENTIAL
RECORD KEY IS CUSTMAST-PKEY-00001-00012
FILE STATUS IS CUSTMAST-STATUS.
*****************************************************************
DATA DIVISION.
FILE SECTION.
FD CUSTRCSV-FILE
DATA RECORD IS CUSTRCSV-REC
.
01 CUSTRCSV-REC.
05 CUSTRCSV-DATA-01 PIC X(00256).
FD CUSTMAST-FILE
DATA RECORD IS CUSTMAST-REC
.
01 CUSTMAST-REC.
05 CUSTMAST-PKEY-00001-00012 PIC X(00012).
05 CUSTMAST-DATA-00013-00500 PIC X(00500).
*****************************************************************
* This program was created with the SYSMASK1.TXT file as input. *
* The SYSMASK1 provides for the sequential reading of the input *
* file and the sequential writing of the output file. *
* *
* If the output file is indexed then the input file must be in *
* sequence by the field that will be used to provide the key *
* for the output file. This is a sequential load process. *
* *
* If the key field is not in sequence then refer to SYSMASK2 *
* to provide for a random add or update of the indexed file. *
* *
* This program mask will have the ASCII/EBCDIC table inserted *
* for use by the /TRANSLATE function of SimoZAPS. *
* *
* For more information or questions please contact SimoTime *
* Technologies. The version control number is 16.01.01 *
* *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
WORKING-STORAGE SECTION.
01 SIM-TITLE.
05 T1 pic X(11) value '* CUSIMPC1 '.
05 T2 pic X(34) value 'CSV RSEQ, Customer KSDS, Seq Load '.
05 T3 pic X(10) value ' v19.00.00'.
05 T4 pic X(24) value ' helpdesk@simotime.com'.
01 SIM-COPYRIGHT.
05 C1 pic X(11) value '* CUSIMPC1 '.
05 C2 pic X(32) value 'This Data File Convert Member wa'.
05 C3 pic X(32) value 's generated by SimoTime Technolo'.
05 C4 pic X(04) value 'gies'.
01 CUSTRCSV-STATUS.
05 CUSTRCSV-STATUS-L pic X.
05 CUSTRCSV-STATUS-R pic X.
01 CUSTRCSV-EOF pic X value 'N'.
01 CUSTRCSV-OPEN-FLAG pic X value 'C'.
01 CUSTMAST-STATUS.
05 CUSTMAST-STATUS-L pic X.
05 CUSTMAST-STATUS-R pic X.
01 CUSTMAST-EOF pic X value 'N'.
01 CUSTMAST-OPEN-FLAG pic X value 'C'.
01 CUSTRCSV-LRECL pic 9(5) value 00256.
01 CUSTMAST-LRECL pic 9(5) value 00512.
01 CUSTRCSV-LRECL-MAX pic 9(5) value 00256.
01 CUSTMAST-LRECL-MAX pic 9(5) value 00512.
*****************************************************************
* 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(011) value '* CUSIMPC1 '.
05 MESSAGE-TEXT.
10 MESSAGE-TEXT-1 pic X(068) value SPACES.
10 MESSAGE-TEXT-2 pic X(188) value SPACES.
01 MSG-LSB pic 9(5) value 267.
*****************************************************************
01 PROGRAM-NAME pic X(8) value 'CUSIMPC1'.
01 INFO-STATEMENT.
05 INFO-SHORT.
10 INFO-ID pic X(8) value 'Starting'.
10 filler pic X(2) value ', '.
10 filler pic X(34)
value 'CSV RSEQ, Customer KSDS, Seq Load '.
05 filler pic X(24)
value ' http://www.SimoTime.com'.
01 APPL-RESULT pic S9(9) comp.
88 APPL-AOK value 0.
88 APPL-EOF value 16.
01 WRITE-FLAG pic X value 'Y'.
01 CUSTRCSV-TOTAL.
05 CUSTRCSV-RDR pic 9(9) value 0.
05 filler pic X(3) value ' - '.
05 filler pic X(23) value 'Line count for CUSTRCSV'.
01 CUSTMAST-TOTAL.
05 CUSTMAST-ADD pic 9(9) value 0.
05 filler pic X(3) value ' - '.
05 filler pic X(23) value 'Line count for CUSTMAST'.
*****************************************************************
PROCEDURE DIVISION.
move all '*' to MESSAGE-TEXT-1
perform Z-DISPLAY-MESSAGE-TEXT
move INFO-STATEMENT to MESSAGE-TEXT-1
perform Z-DISPLAY-MESSAGE-TEXT
move all '*' to MESSAGE-TEXT-1
perform Z-DISPLAY-MESSAGE-TEXT
perform Z-POST-COPYRIGHT
perform CUSTRCSV-OPEN
perform CUSTMAST-OPEN
* USRSOJ Processing not specified...
perform until CUSTRCSV-STATUS not = '00'
perform CUSTRCSV-READ
if CUSTRCSV-STATUS = '00'
add 1 to CUSTRCSV-RDR
perform BUILD-OUTPUT-RECORD
if WRITE-FLAG = 'Y'
perform CUSTMAST-WRITE
if CUSTMAST-STATUS = '00'
add 1 to CUSTMAST-ADD
end-if
end-if
end-if
end-perform
* USREOJ Processing not specified...
move CUSTRCSV-TOTAL to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CUSTMAST-TOTAL to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
if APPL-EOF
move 'Complete' to INFO-ID
else
move 'ABENDING' to INFO-ID
end-if
move INFO-STATEMENT to MESSAGE-TEXT(1:79)
perform Z-DISPLAY-MESSAGE-TEXT
perform CUSTMAST-CLOSE
perform CUSTRCSV-CLOSE
GOBACK.
*****************************************************************
BUILD-OUTPUT-RECORD.
* Import CALL process...
call 'CUSIMPR1' using CUSTMAST-REC
CUSTRCSV-REC
add 00512 to ZERO giving CUSTMAST-LRECL
exit.
*****************************************************************
* I/O Routines for the INPUT File... *
*****************************************************************
CUSTRCSV-CLOSE.
add 8 to ZERO giving APPL-RESULT.
close CUSTRCSV-FILE
if CUSTRCSV-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 CUSTRCSV' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CUSTRCSV-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
CUSTRCSV-READ.
read CUSTRCSV-FILE
if CUSTRCSV-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if CUSTRCSV-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 CUSTRCSV-EOF
else
move 'READ Failure with CUSTRCSV' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CUSTRCSV-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
end-if
exit.
*---------------------------------------------------------------*
CUSTRCSV-OPEN.
add 8 to ZERO giving APPL-RESULT.
open input CUSTRCSV-FILE
if CUSTRCSV-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'O' to CUSTRCSV-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'OPEN Failure with CUSTRCSV' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CUSTRCSV-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*****************************************************************
* I/O Routines for the OUTPUT File... *
*****************************************************************
CUSTMAST-WRITE.
if CUSTMAST-OPEN-FLAG = 'C'
perform CUSTMAST-OPEN
end-if
write CUSTMAST-REC
if CUSTMAST-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if CUSTMAST-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 'WRITE Failure with CUSTMAST' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CUSTMAST-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
CUSTMAST-OPEN.
add 8 to ZERO giving APPL-RESULT.
open OUTPUT CUSTMAST-FILE
if CUSTMAST-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'O' to CUSTMAST-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'OPEN Failure with CUSTMAST' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CUSTMAST-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
CUSTMAST-CLOSE.
add 8 to ZERO giving APPL-RESULT.
close CUSTMAST-FILE
if CUSTMAST-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'C' to CUSTMAST-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'CLOSE Failure with CUSTMAST' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CUSTMAST-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*****************************************************************
* The following Z-ROUTINES provide administrative functions *
* for this program. *
*****************************************************************
* 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.
*****************************************************************
Z-CALCULATE-MESSAGE-LSB.
add 267 to ZERO giving MSG-LSB
perform until MSG-LSB < 80
or MESSAGE-BUFFER(MSG-LSB:1) not = SPACE
if MESSAGE-BUFFER(MSG-LSB:1) = SPACE
subtract 1 from MSG-LSB
end-if
end-perform
exit.
*****************************************************************
* Display CONSOLE messages... *
*****************************************************************
Z-DISPLAY-MESSAGE-TEXT.
perform Z-CALCULATE-MESSAGE-LSB
display MESSAGE-BUFFER(1:MSG-LSB)
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.
*****************************************************************
Z-POST-COPYRIGHT.
display SIM-TITLE
display SIM-COPYRIGHT
exit.
*****************************************************************
* This program was generated by SimoZAPS *
* A product of SimoTime Technologies *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* *
* Generation Date: 2019-08-30 Generation Time: 01:21:20:44 *
*****************************************************************
The following (CUSIMPR1.cbl) is a COBOL program that converts the fields of data. The program reformats the numeric fields and appends trailing spaces to text fields. Each record will contain a group of concatenated data strings. This output record and file structure may be referred to as a row and column architecture.
IDENTIFICATION DIVISION.
PROGRAM-ID. CUSIMPR1.
AUTHOR. SIMOTIME TECHNOLOGIES.
*****************************************************************
* This routine was generated by SimoREC1 *
* A product of SimoTime Technologies *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* Generation Date: 2019/09/22 Generation Time: 22:05:34:29 *
*****************************************************************
DATA DIVISION.
WORKING-STORAGE SECTION.
01 NGPU-07-00.
05 NRPU-07-00 pic 9(07).
01 IX-P1 pic 9(9) value 0.
01 IX-P2 pic 9(9) value 0.
01 IX-NP pic 9(5) value 0.
01 IX-L1 pic 9(9) value 0.
01 RA-P1 pic 9(3) value 0.
01 RA-P2 pic 9(3) value 0.
01 LOOP-CONTROL pic 9(5) value 0.
01 COLUMN-NUMBER pic 9(5) value 0.
01 WORK-AREA-X.
05 WORK-AREA-X1 pic X value '"'.
05 WORK-AREA pic X(00288) value SPACES.
01 WORK-AREA-X2 pic X(00256) value SPACES.
01 FRAME-STOP.
05 FRAME-BYTE pic X value '"'.
05 DELIMITER-BYTE pic X value ','.
01 FRAME-FLAG pic X value 'N'.
01 O-FLAG pic X(3) value 'CSV'.
01 BYTE-Y pic X value 'Y'.
01 BYTE-N pic X value 'N'.
01 FRAME-COUNT pic 9(5) value 0.
01 DELIM-COUNT pic 9(5) value 0.
01 FFL-SIZE pic 9(5) value 0.
01 CSV-SIZE pic 9(5) value 0.
01 TXT-SIZE pic 9(5) value 0.
01 LAST-NON-SPACE-BYTE pic 9(5) value 0.
01 SIGN-BYTE pic X value SPACE.
01 DIG-POS pic 9(3).
01 DIG-LEN pic 9(3).
01 DIG-CTL pic 9(3).
01 DEC-POS pic 9(3).
01 DEC-LEN pic 9(3).
01 DEC-CTL pic 9(3).
01 DEC-POINT pic 9(3).
01 WRK-POS pic 9(3).
*
*****************************************************************
LINKAGE SECTION.
COPY CUSTCB01.
01 REC1CALL-REC pic X(00256).
*
*****************************************************************
PROCEDURE DIVISION using CUST-RECORD
REC1CALL-REC.
*
add 1 to ZERO giving IX-NP
move ZERO to COLUMN-NUMBER
*
* String Move, CUST-NUMBER
add 1 to COLUMN-NUMBER
add 00012 to ZERO giving FFL-SIZE
perform CONVERT-TEXT
perform POST-DATA-TO-FIELD
*
* String Move, CUST-STATUS
add 1 to COLUMN-NUMBER
add 00001 to ZERO giving FFL-SIZE
perform CONVERT-TEXT
perform POST-DATA-TO-FIELD
*
* String Move, CUST-LAST-NAME
add 1 to COLUMN-NUMBER
add 00028 to ZERO giving FFL-SIZE
perform CONVERT-TEXT
perform POST-DATA-TO-FIELD
*
* String Move, CUST-FIRST-NAME
add 1 to COLUMN-NUMBER
add 00020 to ZERO giving FFL-SIZE
perform CONVERT-TEXT
perform POST-DATA-TO-FIELD
*
* String Move, CUST-MID-NAME
add 1 to COLUMN-NUMBER
add 00020 to ZERO giving FFL-SIZE
perform CONVERT-TEXT
perform POST-DATA-TO-FIELD
*
* String Move, CUST-ADDRESS-1
add 1 to COLUMN-NUMBER
add 00048 to ZERO giving FFL-SIZE
perform CONVERT-TEXT
perform POST-DATA-TO-FIELD
*
* String Move, CUST-ADDRESS-2
add 1 to COLUMN-NUMBER
add 00048 to ZERO giving FFL-SIZE
perform CONVERT-TEXT
perform POST-DATA-TO-FIELD
*
* String Move, CUST-CITY
add 1 to COLUMN-NUMBER
add 00028 to ZERO giving FFL-SIZE
perform CONVERT-TEXT
perform POST-DATA-TO-FIELD
*
* String Move, CUST-STATE
add 1 to COLUMN-NUMBER
add 00028 to ZERO giving FFL-SIZE
perform CONVERT-TEXT
perform POST-DATA-TO-FIELD
*
* String Move, CUST-POSTAL-CODE
add 1 to COLUMN-NUMBER
add 00012 to ZERO giving FFL-SIZE
perform CONVERT-TEXT
perform POST-DATA-TO-FIELD
*
* String Move, CUST-PHONE-WORK
add 1 to COLUMN-NUMBER
add 00018 to ZERO giving FFL-SIZE
perform CONVERT-TEXT
perform POST-DATA-TO-FIELD
*
* String Move, CUST-PHONE-CELL
add 1 to COLUMN-NUMBER
add 00018 to ZERO giving FFL-SIZE
perform CONVERT-TEXT
perform POST-DATA-TO-FIELD
*
* Number Move, CUST-CREDIT-LIMIT
* Unsign, PACKED Number
add 1 to COLUMN-NUMBER
add 00004 to ZERO giving FFL-SIZE
perform CONVERT-NUMBER
perform POST-DATA-TO-FIELD
GOBACK.
*
*****************************************************************
CONVERT-NUMBER.
move SPACES to WORK-AREA
move '+' to SIGN-BYTE
perform GET-DATA-CONTENT
* Scan for Explicit Sign and Decimal Point...
move ZERO to DIG-POS
move ZERO to DIG-LEN
move ZERO to DEC-POS
move ZERO to DEC-LEN
move ZERO to DEC-POINT
add 1 to ZERO giving IX-L1
if WORK-AREA(1:1) = '+'
or WORK-AREA(1:1) = '-'
move WORK-AREA(1:1) to SIGN-BYTE
add 1 to IX-L1
end-if
perform
until IX-L1 > 40
or WORK-AREA(IX-L1:1) = SPACE
if WORK-AREA(IX-L1:1) = '+'
or WORK-AREA(IX-L1:1) = '-'
move WORK-AREA(IX-L1:1) to SIGN-BYTE
move SPACES to WORK-AREA(IX-L1:3)
end-if
if WORK-AREA(IX-L1:1) = '.'
add IX-L1 to ZERO giving DEC-POINT
end-if
if WORK-AREA(IX-L1:1) > '0'
and WORK-AREA(IX-L1:1) < '9'
or WORK-AREA(IX-L1:1) = '0'
or WORK-AREA(IX-L1:1) = '9'
if DEC-POINT = ZERO
add 1 to DIG-LEN
if DIG-POS = ZERO
add IX-L1 to DIG-POS
end-if
else
add 1 to DEC-LEN
if DEC-POS = ZERO
add IX-L1 to DEC-POS
end-if
end-if
end-if
add 1 to IX-L1
end-perform
exit.
*
*****************************************************************
CONVERT-TEXT.
move SPACES to WORK-AREA
perform GET-DATA-CONTENT
exit.
*
*****************************************************************
GET-DATA-CONTENT.
* This routine performs a left-to-right scan of a data
* string. A data string may be enclosed within a set
* of framing characters (usually double-quotes).
* Concatenated data strings may be separated by a
* delimiter byte (usually a comma).
* The variable length data value minus the possible
* framing characters and will be placed in a work area
* for use with a fixed-length field format.
*****************************************************************
add 1 to ZERO giving IX-P2
move ZERO to LOOP-CONTROL
move BYTE-N to FRAME-FLAG
if REC1CALL-REC(IX-NP:1) = FRAME-BYTE
move BYTE-Y to FRAME-FLAG
add 1 to IX-NP
end-if
if REC1CALL-REC(IX-NP:1) not = DELIMITER-BYTE
or FRAME-FLAG = BYTE-Y
perform until REC1CALL-REC(IX-NP:1) = DELIMITER-BYTE
and FRAME-FLAG = BYTE-N
or LOOP-CONTROL > FFL-SIZE + 10
if REC1CALL-REC(IX-NP:1) = FRAME-BYTE
if REC1CALL-REC(IX-NP:2) = FRAME-STOP
add 1 to IX-NP
move BYTE-N to FRAME-FLAG
else
add 1 to IX-NP
move REC1CALL-REC(IX-NP:1)
to WORK-AREA(IX-P2:1)
add 1 to IX-NP
add 1 to IX-P2
end-if
else
move REC1CALL-REC(IX-NP:1) to WORK-AREA(IX-P2:1)
if REC1CALL-REC(IX-NP:1) not = SPACE
add IX-P2 to ZERO giving TXT-SIZE
end-if
add 1 to IX-NP
add 1 to IX-P2
end-if
add 1 to LOOP-CONTROL
end-perform
end-if
* Increment past Delimiter Byte
if REC1CALL-REC(IX-NP:1) = DELIMITER-BYTE
add 1 to IX-NP
end-if
exit.
*
*****************************************************************
POST-DATA-TO-FIELD.
evaluate COLUMN-NUMBER
when 001 move WORK-AREA(1:TXT-SIZE)
to CUST-NUMBER
when 002 move WORK-AREA(1:TXT-SIZE)
to CUST-STATUS
when 003 move WORK-AREA(1:TXT-SIZE)
to CUST-LAST-NAME
when 004 move WORK-AREA(1:TXT-SIZE)
to CUST-FIRST-NAME
when 005 move WORK-AREA(1:TXT-SIZE)
to CUST-MID-NAME
when 006 move WORK-AREA(1:TXT-SIZE)
to CUST-ADDRESS-1
when 007 move WORK-AREA(1:TXT-SIZE)
to CUST-ADDRESS-2
when 008 move WORK-AREA(1:TXT-SIZE)
to CUST-CITY
when 009 move WORK-AREA(1:TXT-SIZE)
to CUST-STATE
when 010 move WORK-AREA(1:TXT-SIZE)
to CUST-POSTAL-CODE
when 011 move WORK-AREA(1:TXT-SIZE)
to CUST-PHONE-WORK
when 012 move WORK-AREA(1:TXT-SIZE)
to CUST-PHONE-CELL
* Reformat CUST-CREDIT-LIMIT
when 013 initialize NGPU-07-00
add 07 to ZERO giving DIG-CTL
add 00 to ZERO giving DEC-CTL
if DIG-LEN > 0
if DIG-LEN > DIG-CTL
perform until DIG-LEN < DIG-CTL + 1
subtract 1 from DIG-LEN
add 1 to DIG-POS
end-perform
end-if
compute WRK-POS = DIG-CTL + 1 - DIG-LEN
move WORK-AREA(DIG-POS:DIG-LEN)
to NGPU-07-00(WRK-POS:DIG-LEN)
end-if
if DEC-LEN > 0
if DEC-LEN > DEC-CTL
add DEC-CTL to ZERO giving DEC-LEN
end-if
move WORK-AREA(DEC-POS:DEC-LEN)
to NGPU-07-00(DIG-CTL + 1:DEC-LEN)
end-if
if NRPU-07-00 is NUMERIC
if SIGN-BYTE = '-'
subtract NRPU-07-00 from ZERO
giving CUST-CREDIT-LIMIT
else
add NRPU-07-00 to ZERO
giving CUST-CREDIT-LIMIT
end-if
else
display 'non-Numeric in Numeric Field '
COLUMN-NUMBER
' - ' NGPU-07-00
end-if
end-evaluate
exit.
*****************************************************************
* This routine was generated by SimoREC1 *
* A product of SimoTime Technologies *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* Generation Date: 2019/09/22 Generation Time: 22:05:34:29 *
*****************************************************************
The following (CUSEXTC5.cbl) is the COBOL I/O program that was generated with SimoTime technology. The program was tested using Micro Focus Enterprise Server on Windows/XP.
IDENTIFICATION DIVISION.
PROGRAM-ID. CUSEXTC5.
AUTHOR. SIMOTIME TECHNOLOGIES.
*****************************************************************
* This program was generated by SimoZAPS *
* A product of SimoTime Technologies *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* *
* Generation Date: 2020-06-16 Generation Time: 02:12:28:04 *
* *
* Record Record Key *
* Function Name Organization Format Max-Min Pos-Len *
* PRIMARY CUSTMAST INDEXED VARIABLE 00512 00001 *
* 00012 00012 *
* SECONDARY CUSTLCSV ASCII/CRLF FIXED 01024 *
* *
*****************************************************************
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CUSTMAST-FILE ASSIGN TO CUSTMAST
ORGANIZATION IS INDEXED
ACCESS MODE IS SEQUENTIAL
RECORD KEY IS CUSTMAST-PKEY-00001-00012
FILE STATUS IS CUSTMAST-STATUS.
SELECT CUSTLCSV-FILE ASSIGN TO CUSTLCSV
ORGANIZATION IS LINE SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS CUSTLCSV-STATUS.
*****************************************************************
DATA DIVISION.
FILE SECTION.
FD CUSTMAST-FILE
DATA RECORD IS CUSTMAST-REC
.
01 CUSTMAST-REC.
05 CUSTMAST-PKEY-00001-00012 PIC X(00012).
05 CUSTMAST-DATA-00013-00500 PIC X(00500).
FD CUSTLCSV-FILE
DATA RECORD IS CUSTLCSV-REC
.
01 CUSTLCSV-REC.
05 CUSTLCSV-DATA-01 PIC X(01024).
*****************************************************************
* This program was created with the SYSMASK1.TXT file as input. *
* The SYSMASK1 provides for the sequential reading of the input *
* file and the sequential writing of the output file. *
* *
* If the output file is indexed then the input file must be in *
* sequence by the field that will be used to provide the key *
* for the output file. This is a sequential load process. *
* *
* If the key field is not in sequence then refer to SYSMASK2 *
* to provide for a random add or update of the indexed file. *
* *
* This program mask will have the ASCII/EBCDIC table inserted *
* for use by the /TRANSLATE function of SimoZAPS. *
* *
* For more information or questions please contact SimoTime *
* Technologies. The version control number is 20.00.00 *
* *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
WORKING-STORAGE SECTION.
01 SIM-TITLE.
05 T1 pic X(11) value '* CUSEXTC5 '.
05 T2 pic X(34) value 'Convert Customer ASC-KSDS to LCSV '.
05 T3 pic X(10) value ' v20.00.00'.
05 T4 pic X(24) value ' helpdesk@simotime.com'.
01 SIM-COPYRIGHT.
05 C1 pic X(11) value '* CUSEXTC5 '.
05 C2 pic X(32) value 'This Data File Convert Member wa'.
05 C3 pic X(32) value 's generated by SimoTime Technolo'.
05 C4 pic X(04) value 'gies'.
01 CUSTMAST-STATUS.
05 CUSTMAST-STATUS-L pic X.
05 CUSTMAST-STATUS-R pic X.
01 CUSTMAST-EOF pic X value 'N'.
01 CUSTMAST-OPEN-FLAG pic X value 'C'.
01 CUSTLCSV-STATUS.
05 CUSTLCSV-STATUS-L pic X.
05 CUSTLCSV-STATUS-R pic X.
01 CUSTLCSV-EOF pic X value 'N'.
01 CUSTLCSV-OPEN-FLAG pic X value 'C'.
01 CUSTMAST-LRECL pic 9(5) value 00512.
01 CUSTLCSV-LRECL pic 9(5) value 01024.
01 CUSTMAST-LRECL-MAX pic 9(5) value 00512.
01 CUSTLCSV-LRECL-MAX pic 9(5) value 01024.
*****************************************************************
* 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-TO-SYSOUT routine. *
*****************************************************************
01 MESSAGE-BUFFER.
05 MESSAGE-HEADER pic X(011) value '* CUSEXTC5 '.
05 MESSAGE-TEXT.
10 MESSAGE-TEXT-1 pic X(068) value SPACES.
10 MESSAGE-TEXT-2 pic X(188) value SPACES.
01 MSG-LSB pic 9(5) value 267.
*****************************************************************
01 PROGRAM-NAME pic X(8) value 'CUSEXTC5'.
01 INFO-STATEMENT.
05 INFO-SHORT.
10 INFO-ID pic X(8) value 'Starting'.
10 filler pic X(2) value ', '.
10 filler pic X(34)
value 'Convert Customer ASC-KSDS to LCSV '.
05 filler pic X(24)
value ' http://www.SimoTime.com'.
01 APPL-RESULT pic S9(9) comp.
88 APPL-AOK value 0.
88 APPL-EOF value 16.
01 WRITE-FLAG pic X value 'Y'.
01 CUSTMAST-TOTAL.
05 CUSTMAST-RDR pic 9(9) value 0.
05 filler pic X(3) value ' - '.
05 filler pic X(23) value 'Line count for CUSTMAST'.
01 CUSTLCSV-TOTAL.
05 CUSTLCSV-ADD pic 9(9) value 0.
05 filler pic X(3) value ' - '.
05 filler pic X(23) value 'Line count for CUSTLCSV'.
*****************************************************************
PROCEDURE DIVISION.
move all '*' to MESSAGE-TEXT-1
perform Z-DISPLAY-MESSAGE-TO-SYSOUT
move INFO-STATEMENT to MESSAGE-TEXT-1
perform Z-DISPLAY-MESSAGE-TO-SYSOUT
move all '*' to MESSAGE-TEXT-1
perform Z-DISPLAY-MESSAGE-TO-SYSOUT
perform Z-POST-COPYRIGHT
perform CUSTMAST-OPEN
perform CUSTLCSV-OPEN
* USRSOJ Processing not specified...
perform until CUSTMAST-STATUS not = '00'
perform CUSTMAST-READ
if CUSTMAST-STATUS = '00'
add 1 to CUSTMAST-RDR
move 'Y' to WRITE-FLAG
perform BUILD-OUTPUT-RECORD
if WRITE-FLAG = 'Y'
perform CUSTLCSV-WRITE
if CUSTLCSV-STATUS = '00'
add 1 to CUSTLCSV-ADD
end-if
end-if
end-if
end-perform
* USREOJ Processing not specified...
move CUSTMAST-TOTAL to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TO-USERS
move CUSTLCSV-TOTAL to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TO-USERS
if APPL-EOF
move 'Complete' to INFO-ID
else
move 'ABENDING' to INFO-ID
end-if
move INFO-STATEMENT to MESSAGE-TEXT(1:79)
perform Z-DISPLAY-MESSAGE-TO-SYSOUT
perform CUSTLCSV-CLOSE
perform CUSTMAST-CLOSE
GOBACK.
*****************************************************************
BUILD-OUTPUT-RECORD.
* Extract CALL process...
call 'CUSEXTR5' using CUSTLCSV-REC
CUSTMAST-REC
add 01024 to ZERO giving CUSTLCSV-LRECL
exit.
*****************************************************************
* I/O Routines for the INPUT File... *
*****************************************************************
CUSTMAST-CLOSE.
add 8 to ZERO giving APPL-RESULT.
close CUSTMAST-FILE
if CUSTMAST-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 CUSTMAST' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TO-USERS
move CUSTMAST-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
CUSTMAST-READ.
read CUSTMAST-FILE
if CUSTMAST-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if CUSTMAST-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 CUSTMAST-EOF
else
move 'READ Failure with CUSTMAST' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TO-USERS
move CUSTMAST-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
end-if
exit.
*---------------------------------------------------------------*
CUSTMAST-OPEN.
add 8 to ZERO giving APPL-RESULT.
open input CUSTMAST-FILE
if CUSTMAST-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'O' to CUSTMAST-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'OPEN Failure with CUSTMAST' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TO-USERS
move CUSTMAST-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*****************************************************************
* I/O Routines for the OUTPUT File... *
*****************************************************************
CUSTLCSV-WRITE.
if CUSTLCSV-OPEN-FLAG = 'C'
perform CUSTLCSV-OPEN
end-if
write CUSTLCSV-REC
if CUSTLCSV-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if CUSTLCSV-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 'WRITE Failure with CUSTLCSV' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TO-USERS
move CUSTLCSV-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
CUSTLCSV-OPEN.
add 8 to ZERO giving APPL-RESULT.
open OUTPUT CUSTLCSV-FILE
if CUSTLCSV-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'O' to CUSTLCSV-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'OPEN Failure with CUSTLCSV' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TO-USERS
move CUSTLCSV-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
CUSTLCSV-CLOSE.
add 8 to ZERO giving APPL-RESULT.
close CUSTLCSV-FILE
if CUSTLCSV-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'C' to CUSTLCSV-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'CLOSE Failure with CUSTLCSV' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TO-USERS
move CUSTLCSV-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*****************************************************************
* The following Z-ROUTINES provide administrative functions *
* for this program. *
*****************************************************************
* 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-TO-USERS
end-if
move 'PROGRAM-IS-ABENDING...' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TO-USERS
add 12 to ZERO giving RETURN-CODE
STOP RUN.
* exit.
*****************************************************************
Z-CALCULATE-MESSAGE-LSB.
add 267 to ZERO giving MSG-LSB
perform until MSG-LSB < 80
or MESSAGE-BUFFER(MSG-LSB:1) not = SPACE
if MESSAGE-BUFFER(MSG-LSB:1) = SPACE
subtract 1 from MSG-LSB
end-if
end-perform
exit.
*****************************************************************
* Post message to the SYSOUT device, clear message buffer... *
*****************************************************************
Z-DISPLAY-MESSAGE-TO-SYSOUT.
perform Z-CALCULATE-MESSAGE-LSB
display MESSAGE-BUFFER(1:MSG-LSB)
move all SPACES to MESSAGE-TEXT
exit.
*****************************************************************
* Display message to console, do not clear message buffer... *
*****************************************************************
Z-DISPLAY-MESSAGE-TO-CONSOLE.
perform Z-CALCULATE-MESSAGE-LSB
display MESSAGE-BUFFER(1:MSG-LSB) upon console
exit.
*****************************************************************
* Display message to console and post to SYSOUT device... *
*****************************************************************
Z-DISPLAY-MESSAGE-TO-USERS.
perform Z-DISPLAY-MESSAGE-TO-CONSOLE
perform Z-DISPLAY-MESSAGE-TO-SYSOUT
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-TO-USERS
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-TO-USERS
end-if
exit.
*****************************************************************
Z-POST-COPYRIGHT.
display SIM-TITLE
display SIM-COPYRIGHT
exit.
*****************************************************************
* This program was generated by SimoZAPS *
* A product of SimoTime Technologies *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* *
* Generation Date: 2020-06-16 Generation Time: 02:12:28:05 *
*****************************************************************
The following two sections describe the input files that are required for the program generation process.
The Process Control File will be used to generate the COBOL programs that will extract data from the customer master file and create a record sequential with the fields separated by a comma. The input file (CUSTMAST.dat) is a Micro Focus Key-Sequenced file. The output file may be easily imported into an Excel spread sheet. The following (CUSIMP01.pcf) shows the content of the Process Control File.
*********************************************************************** * CUSIMP01.pcf - a Process Control File * * SimoTime Program Generation Technologies * * (C) Copyright 1987-2019 All Rights Reserved * * Web Site URL: http://www.simotime.com * * e-mail: helpdesk@simotime.com * *********************************************************************** * SYSUT1 is a Record Sequential file, 256-byte fixed-length records. * SYSUT2 is the Customer Master File, Indexed, 512-byte records. *********************************************************************** * This set of specification will generate a callable COBOL routine * that will import data from a record sequential with the fields * within the records separated by a comma and create a new customer * master file. The new customer master file will be a VSAM, KSDS with * Fixed Field Lengths. * * The following group of statements will define the high level * functions and processes to be performed. * &SIMOPREP call ..\..\ENV1BASE &USERPREP call USERCONV &CONFORM IBM ©FILE CUSTCB01.cpy &HTMLFILE custcb01.htm * * The following group of statements will define the behavioral * characteristics and environment variable for the file I/O Program * to be generated. * *HEAD34 ....:....1....:....2....:....3.... &HEAD34 CSV RSEQ, Customer KSDS, Seq Load &VSAMLOAD SEQUENTIAL &PROGID CUSIMPC1 &SYSUT1 name=CUSTRCSV org=Sequential recfm=FIXED rlen=256 &SYSUT2 name=CUSTMAST org=Indexed recfm=VARIABLE rmax=512 kpos=1 klen=12 * * The following two statements are used when the records in the data * file (input or output) are a Comma-Separated-Values (or CSV) format. * &DELIMITER , &FRAME " * * The following group of statements will define the behavioral * characteristics and environment variables for the record content * conversion program to be generated. * This is for CSV Formatted input records. * &IMPCALL CUSIMPR1 &IMPREC CUST-RECORD &IMPLREC 256 &IMPFMT CSV , &IMPINIT SPACES &IMPHDR YES * * The following group of statements will define the fields to be * imported from the input file and written to the output file. * conversion program to be generated. * This is for CSV Formatted input records. * &IMPORT CUST-NUMBER &IMPORT CUST-STATUS &IMPORT CUST-LAST-NAME &IMPORT CUST-FIRST-NAME &IMPORT CUST-MID-NAME &IMPORT CUST-ADDRESS-1 &IMPORT CUST-ADDRESS-2 &IMPORT CUST-CITY &IMPORT CUST-STATE &IMPORT CUST-POSTAL-CODE &IMPORT CUST-PHONE-HOME &IMPORT CUST-PHONE-WORK &IMPORT CUST-PHONE-CELL &IMPORT CUST-CREDIT-LIMIT &IMPORT CUST-DISCOUNT-CODE(1) &IMPORT CUST-DISCOUNT-RATE(1) &IMPORT CUST-DISCOUNT-DATE(1) &IMPORT CUST-DISCOUNT-CODE(2) &IMPORT CUST-DISCOUNT-RATE(2) &IMPORT CUST-DISCOUNT-DATE(2) &IMPORT CUST-DISCOUNT-CODE(3) &IMPORT CUST-DISCOUNT-RATE(3) &IMPORT CUST-DISCOUNT-DATE(3) &IMPORT CUST-LADATE &IMPORT CUST-LATIME &IMPORT CUST-TOKEN *IMPORT FILLER-00041-0000368 * &END
The following (CUSTCB01.cpy) is the COBOL copy file that is used to define the record structure.
*****************************************************************
* CUSTCB01.cpy - a COBOL Copy Member *
* Customer Master File used for Quality Assurance Testing *
* This is a VSAM Keyed-Sequential-Data-Set or KSDS *
* Copyright (C) 1987-2020 SimoTime Technologies *
* All Rights Reserved *
* Provided by SimoTime Technologies *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
* CUST-RECORD size is 512 bytes.
* RMIN is 512 RMAX is 512
* KPOS is 1 KLEN is 012
*
....:.*..1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
01 CUST-RECORD.
05 CUST-NUMBER PIC X(12). col A
05 CUST-DATA.
10 CUST-STATUS PIC X. col B
10 CUST-NAME.
15 CUST-LAST-NAME PIC X(28). col C
15 CUST-FIRST-NAME PIC X(20). col D
15 CUST-MID-NAME PIC X(20). col E
10 CUST-ADDRESS-1 PIC X(48). col F
10 CUST-ADDRESS-2 PIC X(48). col G
10 CUST-CITY PIC X(28). col H
10 CUST-STATE PIC X(28). col I
10 CUST-POSTAL-CODE PIC X(12). col J
10 CUST-PHONE-HOME PIC X(18). col K
10 CUST-PHONE-WORK PIC X(18). col L
10 CUST-PHONE-CELL PIC X(18). col M
10 CUST-CREDIT-LIMIT PIC 9(7) COMP-3. col N
10 CUST-DISCOUNT OCCURS 3 TIMES.
15 CUST-DISCOUNT-CODE PIC S9(3) COMP. col ORU
15 CUST-DISCOUNT-RATE PIC S9(2)V999. col PSV
15 CUST-DISCOUNT-DATE PIC X(8). col QTW
10 CUST-LADATE PIC X(8). col X
10 CUST-LATIME PIC X(8). col Y
10 CUST-TOKEN PIC 9(3). col Z
10 FILLER PIC X(145).
*
*** CUSTCB01 - End-of-Copy File - - - - - - - - - - - CUSTCB01 *
*****************************************************************
*
The SimoTime Technologies have the ability to scan a COBOL copy file and create an HTML document of a record structure or record layout. The HTML documentation provides information that is not easy to obtain by viewing the COBOL copy file. For example, the physical position of a field within a record as calculated during the copy file scan and placed in the HTML document.
Explore the Record Structure for the Customer Master File by viewing a generated HTML document based on a User-Defined COBOL copyfile.
The purpose of this program is to provide an example for accessing a VSAM, KSDS and extracting data that is reformatted into a comma separated data string that is written to a sequential file. This document may be used as a tutorial for new programmers or as a quick reference for experienced programmers.
In the world of programming there are many ways to solve a problem. This documentation and software were developed and tested on systems that are configured for a SIMOTIME environment based on the hardware, operating systems, user requirements and security requirements. Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration.
SIMOTIME Services has experience in moving or sharing data or application processing across a variety of systems. For additional information about SIMOTIME Services or Technologies please contact us using the information in the Contact or Feedback section of this document.
Software Agreement and Disclaimer
Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Technologies. Once the fee is received by SimoTime the latest version of the software, documentation or training material 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 Technologies.
SimoTime Technologies makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose. It is provided "AS IS" without any expressed or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Technologies 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, documentation or training material.
This section includes links to documents with additional information that are beyond the scope and purpose of this document. The first group of documents may be available from a local system or via an internet connection, the second group of documents will require an internet connection.
Note: A SimoTime License is required for the items to be made available on a local system or server.
The following links may be to the current server or to the Internet.
Explore How to Convert a Fixed-Field-Length Record Structure to a Comma-Separated-Values Record Structure. This technique is used to extract data from a VSAM, Key-Sequenced-Data-Set (KSDS) with a record structure that uses fixed-length fields. The new CSV format may be easily loaded into an Excel spread sheet.
Explore How to Generate a Data File Convert Program using simple specification statements in a Process Control File (PCF). This link to the User Guide includes the information necessary to create a Process Control File and generate the COBOL programs that will do the actual data file conversion. The User Guide contains a list of the PCF statements that are used for the data file convert process.
Explore the capabilities of the SimoZAPS Utility Program. This includes generating a COBOL program that will do the conversion of sequential and VSAM (KSDS) files between EBCDIC and ASCII while maintaining mainframe (or COBOL) numeric formats and integrity. SimoZAPS can 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.
Explore the non-Relational Data Connection for more examples of accessing methodologies and coding techniques for Data Files and VSAM Data Sets.
Explore The ASCII and EBCDIC Translation Tables. These tables are provided for individuals that need to better understand the bit structures and differences of the encoding formats.
Explore The File Status Return Codes that are used to interpret the results of accessing VSAM data sets and/or QSAM files.
The following links will require an internet connect.
This suite of programs and documentation is available to download for review and evaluation purposes. Other uses will require a SimoTime Software License. Link to an Evaluation zPAK Option that includes the program members, documentation and control files.
A good place to start is The SimoTime Home Page for access to white papers, program examples and product information. This link requires an Internet Connection
Explore The Micro Focus Web Site for more information about products (including Micro Focus COBOL) and services available from Micro Focus. This link requires an Internet Connection.
Explore the GnuCOBOL Technologies available from SourceForge. SourceForge is an Open Source community resource dedicated to helping open source projects be as successful as possible. GnuCOBOL (formerly OpenCOBOL) is a COBOL compiler with run time support. The compiler (cobc) translates COBOL source to executable using intermediate C, designated C compiler and linker. This link will require an Internet Connection.
Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.
This document was created and is maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please use the following contact information.
| 1. | Send an e-mail to our helpdesk. |
| 1.1. | helpdesk@simotime.com. |
| 2. | Our telephone numbers are as follows. |
| 2.1. | 1 415 763-9430 office-helpdesk |
| 2.2. | 1 415 827-7045 mobile |
We appreciate hearing from you.
SimoTime Technologies was founded in 1987 and 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. Our customers include small businesses using Internet technologies to corporations using very large mainframe systems.
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. We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms.
Preparing the application programs will require the transfer of source members that will be compiled and deployed on the target platform. The data will need to be transferred between the systems and may need to be converted and validated at various stages within the process. SimoTime has the technology, services and experience to assist in the application and data management tasks involved with doing business in a multi-system environment.
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 |
| Import Data into Customer Master File from Sequential CSV File |
| Copyright © 1987-2025 SimoTime Technologies and Services All Rights Reserved |
| When technology complements business |
| http://www.simotime.com |