![]() |
File Conversion & Formatting Mainframe and PC http://www.simotime.com Copyright © 1987-2010 SimoTime Enterprises All Rights Reserved |
| Table of Contents | Version 09.05.17 |
|
|
There are many options available when moving and converting data between an IBM Mainframe and a Windows or Unix environment. This document will discuss the cycle of how to convert a VSAM, KSDS to a flat Sequential file on the mainframe, download the flat sequential file from the mainframe to the PC and create an Indexed file of ASCII content on the PC.
A general guideline to follow is, "The scope of effort for converting a mainframe legacy file from EBCDIC to ASCII is directly proportional to the size of the file, the age of the file and the number and type of numeric fields." Estimating the time for conversion between EBCDIC and ASCII can be done with a high degree of accuracy. Estimating the time for "scrubbing the data" may be a challenging task.
Additional programs are included for converting ASCII, Text files to Indexed files. These examples also show how to manage Packed-Decimal and BINARY or COMP fields.
In the world of programming there are many ways to solve a problem. This suite of programs is provided as an example of one of the possible solutions to the problems of file conversion. The intent is to keep the programming effort simple and do the conversion as quickly as possible.
The programs have been tested on an IBM mainframe, Mainframe Express from Micro Focus and Net Express from Micro Focus. Sample projects may be obtainf for Mainframe Express and Net Express by sending an e-mail to: helpdesk@simotime.com
Note: The source code and documentation for this suite of examples is available from the SimoTime Library under Download Directory at www.simotime.com
This is an example of how a COBOL program can read a VSAM Keyed Sequential Data Set (KSDS) with EBCDIC content and create a sequential file with EBCDIC content. The example then describes how to translate the EBCDIC content to ASCII and write an ASCII file. At first glance the conversion between EBCDIC and ASCII appears to be a simple and practical task. Typically the EBCDIC files reside on a mainframe legacy system. These files may be very large and may have been updated over a period on many years. In addition to containing displayable EBCDIC characters the records may contain binary and packed decimal fields that cannot simply be converted using an EBCDIC/ASCII table. Also, some of the fields in a record may contains low-values (i.e. x'00') that are being handle as a space characters on the mainframe. The low-values remain low-values when converted to ASCII and when downloaded or ported to the PC these low-values may be treated as null characters and this could present a problem if not addressed in the initial conversion process.
The COBOL source code for the conversions programs was generated using SimoZAPS, a product of SimoTime Enterprises. The SimoZAPS utility program also has the capability of reading, writing or converting between other file formats. In the world of programming there are many ways to solve a problem. This suite of programs is provided as a COBOL example of one of the possible solutions to the problem of changing the contents and structure of data files.
The programs and data files used in this example use a file naming format that is eight (8) characters long with a three (3) character extension.
The member names used in this suite of examples are eight (8) characters long with a three (3) character extension.
| Position | Description | ||||||||||
| 1-2 |
|
||||||||||
| 3 |
|
||||||||||
| 4-5 |
|
||||||||||
| 6 |
|
||||||||||
| 7 |
|
||||||||||
| 8 |
|
The data files used in this example are eight (8) characters long with a three (3) character extension.
| Position | Description | ||||||||
| 1-2 |
|
||||||||
| 3 |
|
||||||||
| 4-5 |
|
||||||||
| 6-8 |
|
The following shows the file conversion cycle or process when transferring files between the host system (in this example the host system is an IBM mainframe) and the PC/Windows environment. This illustration also shows the process for converting between ASCII/Text files and Indexed files.
|
This section contains a number of example programs to do data file conversion between EBCDIC and ASCII. Two of the programs (TXAKSAC1.CBL and KSATXAC1.CBL) illustrate a process for converting packed-decimal and COMP fields to and from character-oriented numeric fields.
Once the COBOL source code has been generated it needs to be compiled. The following three .BAT files are provided to set the environment variables, generate the programs and compile the programs.
| Member | Description |
| ZENVST01.BAT | This batch file will set the environment variables and is called by the following two .BAT files. |
| ZGENST01.TXT | This .BAT file will generate all the COBOL source code used in this project. |
| ZCBLST01.CBL | This i.BAT file will compile all the COBOL programs used in this project. |
The following is the .BAT file used to set the environment variables
@echo off
echo ****************************************************************
echo * This program is provided by: *
echo * SimoTime Enterprises, LLC *
echo * (C) Copyright 1987-2010 All Rights Reserved *
echo * Web Site URL: http://www.simotime.com *
echo * e-mail: helpdesk@simotime.com *
echo ****************************************************************
echo * %0 is STARTING...
echo * %0 is STARTING... >XENVST01.LOG
echo * This process will set the envariables for the demoST01.BAT
echo *
SET COBCPY=.;..\
SET DATACNTL=d:\simonxe1\st01\datacntl
rem *
set path=d:\Net Express;d:\Net Express\base\bin;path=%path%
rem *
set ENV4ST01=YES
rem *
echo * %0 path is %path%
echo * >>XENVST01.LOG
echo * %0 path is as follows... >>XENVST01.LOG
echo * >>XENVST01.LOG
echo * %path% >>XENVST01.LOG
echo * >>XENVST01.LOG
rem *
echo * %0 is COMPLETE...
echo * %0 is COMPLETE... >>XENVST01.LOG
The following is the .Bat file for generating the COBOL source code.
@echo off
echo ****************************************************************
echo * This program is provided by: *
echo * SimoTime Enterprises, LLC *
echo * (C) Copyright 1987-2010 All Rights Reserved *
echo * Web Site URL: http://www.simotime.com *
echo * e-mail: helpdesk@simotime.com *
echo ****************************************************************
echo * %0 is STARTING...
echo * %0 is STARTING... >>XGENST01.LOG
echo * This batch file generates the COBOL source code for the Demo.
echo *
if exist XGENST01.LOG erase XGENST01.LOG
if "%ENV4ST01%" == "YES" goto :SKIPENV
CALL zENVst01.bat
:SKIPENV
rem *
setlocal
call :GENERATE KSASQEM1 KSASQEC1
call :GENERATE KSATXAM1 KSATXAC1
call :GENERATE KSESQEM1 KSESQEC1
call :GENERATE SQEKSAM1 SQEKSAC1
call :GENERATE SQEKSEM1 SQEKSEC1
call :GENERATE SQEKSEM2 SQEKSEC2
call :GENERATE TXAKSAM1 TXAKSAC1
call :GENERATE TXAKSAM2 TXAKSAC2
rem *
dir XGENST01.LOG
type XGENST01.LOG
echo * %0 is COMPLETE...
echo * %0 is COMPLETE... >>XGENST01.LOG
goto :END
:GENERATE
echo * %1 COBOL Generation is STARTING...
if exist %1.cbl erase %1.cbl
rem *
call %1
if exist %2.CBL echo * 0% %1 generation SUCCESSFUL...
if exist %2.CBL echo * 0% %1 generation SUCCESSFUL... >>XGENST01.LOG
if exist %2.CBL goto :END
echo * 0% %1 generation FAILURE!!!... >>XGENST01.LOG
:END
The following is the .BAT file for compiling the COBOL programs.
@echo off
echo ****************************************************************
echo * This program is provided by: *
echo * SimoTime Enterprises, LLC *
echo * (C) Copyright 1987-2010 All Rights Reserved *
echo * Web Site URL: http://www.simotime.com *
echo * e-mail: helpdesk@simotime.com *
echo ****************************************************************
echo * %0 is STARTING...
echo * %0 is STARTING... >>XCBLST01.LOG
echo * This process will compile all the COBOL programs for the Demo.
echo *
if exist XCBLST01.LOG erase XCBLST01.LOG
if "%ENV4ST01%" == "YES" goto :SKIPENV
CALL zENVst01.bat
:SKIPENV
rem *
setlocal
call :COMPILE KSASQEC1
call :COMPILE KSATXAC1
call :COMPILE KSESQEC1
call :COMPILE SQEKSAC1
call :COMPILE SQEKSEC1
call :COMPILE SQEKSEC2
call :COMPILE TXAKSAC1
call :COMPILE TXAKSAC2
rem *
dir XCBLST01.LOG
type XCBLST01.LOG
echo * %0 is COMPLETE...
echo * %0 is COMPLETE... >>XCBLST01.LOG
goto :END
:COMPILE
echo * %0 %1 COBOL Compile is STARTING...
if exist %1.idy erase %1.idy
if exist %1.obj erase %1.obj
if exist %1.dll erase %1.dll
if exist %1.gnt erase %1.gnt
if exist %1.int erase %1.int
rem *
cobol %1.CBL noanim omf(gnt) assign(external);
if exist %1.GNT echo * %0 %1 compiled with NO ANIMATE...
if exist %1.GNT echo * %0 %1 compiled with NO ANIMATE... >>XCBLST01.LOG
if exist %1.GNT goto :END
echo * %0 %1 Compile failure!!! >>XCBLST01.LOG
:END
Read a VSAM Keyed Sequential Data Set (KSDS) with EBCDIC content and create a sequential file with EBCDIC content. This program is intended to run on a mainframe but will also run on a PC with Micro Focus Mainframe Express. This program does not convert the content of the records within the file. It simply creates a new file type (i.e. VSAM, KSDS to a flat sequential file).
The KSESQEx1.ext files are used to generate, compile and execute the file conversion programs.
| Member | Description |
| KSESQEM1.BAT | This batch file will execute the SimoZAPS utility to create a COBOL program that will do the file conversion. |
| KSESQET1.TXT | This is the specificatons file that is read by the SimoZAPS Generation Function. The content of this file will be used by the preceding batch file to generate the COBOL source member that will do the specified file conversion. |
| KSESQEC1.CBL | This is the generated COBOL source member that reads a VSAM, KSDS and creates a QSAM or sequential file. |
The following flowchart is a quick overview of the process for generating the COBOL source code to do the file conversion and formating.
|
The batch file for running the program to generate COBOL source code. | ||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|
|
|
Read the input file (KSESQET1) containing the specifications for generating the source code and create a new file (KSESQEC1) containing the generated COBOL source code. | ||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
Download the sequential file from the mainframe to the PC using FTP (File Transfer Protocol). Since the file contains EBCDIC characters, decimal-packed and COMP data it will be necessary to download in a BINARY format.
Note: Micro Focus provides a Mainframe Access (MFA)option with their Mainframe Express product. The MFA option may be used to download a sequential or VSAM file from the mainframe to the PC with a simple point-and-click or command line procedure.
This program is intended to run on the PC using Micro Focus Net Express (it will also run on the mainframe and the PC with Mainframe Express). It will convert both the file type (i.e. Sequential to Indexed) and the content of the records within the file. Packed-decimal and COMP fields are copied as appropriate. Character fields are converted from EBCDIC to ASCII.
The SQEKSA?1.ext files are used to generate the file conversion program.
| Member | Description |
| SQEKSAM1.BAT | This batch file will execute the SimoZAPS utility to create a COBOL program that will do the file conversion. |
| SQEKSAT1.TXT | This is the specificatons file that is read by the SimoZAPS Generation Function. The content of this file will be used by the preceding batch file to generate the COBOL source member that will do the specified file conversion. |
| SQEKSAC1.CBL | This is the generated COBOL source member that reads a Sequential EBCDIC file and creates an ASCII, Indexed file. |
The following flowchart is a quick overview of the process for generating the COBOL source code to do the file conversion and formating.
|
The batch file for running the program to generate COBOL source code. | ||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|
|
|
Read the input file SQEKSAT1) containing the specifications for generating the source code and create a new file SQEKSAC1) containing the generated COBOL source code. | ||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
This program is intended to run on the PC using Micro Focus Net Express (it will also execute on the PC with Mainframe Express or the mainframe). It will convert both the file type (i.e. Indexed to Sequential) and the content of the records within the file. Packed-decimal and COMP fields are copied as appropriate. Character fields are converted from ASCII to EBCDIC.
The KSASQE?1.ext files are used to generate the file conversion program.
| Member | Description |
| KSASQEM1.BAT | This batch file will execute the SimoZAPS utility to create a COBOL program that will do the file conversion. |
| KSASQET1.TXT | This is the specificatons file that is read by the SimoZAPS Generation Function. The content of this file will be used by the preceding batch file to generate the COBOL source member that will do the specified file conversion. |
| KSASQEC1.CBL | This is the generated COBOL source member that reads a Sequential EBCDIC file and creates an ASCII, Indexed file. |
The following flowchart is a quick overview of the process for generating the COBOL source code to do the file conversion and formating.
|
The batch file for running the program to generate COBOL source code. | ||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|
|
|
Read the input file KSASQET1) containing the specifications for generating the source code and create a new file KSASQEC1) containing the generated COBOL source code. | ||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
Upload the sequential file from the mainframe to the PC using FTP (File Transfer Protocol). Since the file contains EBCDIC character, decimal-packed and COMP data it will be necessary to upload in a BINARY format.
Read a Sequential file with EBCDIC content and create a VSAM Keyed Sequential Data Set (KSDS) with EBCDIC content. This program is intended to run on a mainframe and will run on a PC with Micro Focus Mainframe Express (it will also execute on the PC with Net Express). This program does not convert the content of the records within the file. It simply copies the records to the new file type (i.e. flat sequential file to a VSAM, KSDS).
The SQEKSEx1.ext files are used to generate, compile and execute the file conversion programs.
| Member | Description |
| SQEKSEM1.BAT | This batch file will execute the SimoZAPS utility to create a COBOL program that will do the file conversion. |
| SQEKSET1.TXT | This is the specificatons file that is read by the SimoZAPS Generation Function. The content of this file will be used by the preceding batch file to generate the COBOL source member that will do the specified file conversion. |
| SQEKSEC1.CBL | This is the generated COBOL source member that reads a VSAM, KSDS and creates a QSAM or sequential file. |
The following flowchart is a quick overview of the process for generating the COBOL source code to do the file conversion and formating.
|
The batch file for running the program to generate COBOL source code. | ||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|
|
|
Read the input file (SQEKSET1) containing the specifications for generating the source code and create a new file (SQEKSEC1) containing the generated COBOL source code. | ||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
The following examples show how to convert between Indexed files and ASC/Text files. Since the COBOL programs contains the file definition of "ORGANIZATION IS LINE SEQUENTIAL" on the "SELECT" statement this program will not compile on the mainframe. The programs have been compiled and executed on the PC using Micro Focus Net Express.
This generated sample program will read an Indexed file with ASCII content and create a Text file with ASCII content. This example will also convert a packed-decimal (i.e. COMP-3) and BINARY (i.e. COMP) field to a printable numeric field.
The KSATXA?1.ext files are used to generate the file conversion program.
| Member | Description |
| KSATXAM1.BAT | This batch file will execute the SimoZAPS utility to create a COBOL program that will do the file conversion. |
| KSATXAT1.TXT | This is the specificatons file that is read by the SimoZAPS Generation Function. The content of this file will be used by the preceding batch file to generate the COBOL source member that will do the specified file conversion. |
| KSATXAC1.CBL | This is the generated COBOL source member that reads an Indexed ASCII and creates an ASCII/Text. |
The following flowchart is a quick overview of the process for generating the COBOL source code to do the file conversion and formating.
|
The batch file for running the program to generate COBOL source code. | ||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|
|
|
Read the input file (KSATXAT1) containing the specifications for generating the source code and create a new file (KSATXAC1) containing the generated COBOL source code. | ||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
This step acknowledges that the ASCII/Text file may be viewed or updated using a standard editor program such as NotePAD.
This generated sample program will read a Text file with ASCII content and create a Indexed file with ASCII content.. This example does an ordered load of the Indexed file and may be used to create a new file. Since it is an ordered load the ASCII/Text file must be in sequence by the key-field. This example will also create a packed-decimal (i.e. COMP-3) and BINARY (i.e. COMP) field
The TXAKSA?1.ext files are used to generate the file conversion program.
| Member | Description |
| TXAKSAM1.BAT | This batch file will execute the SimoZAPS utility to create a COBOL program that will do the file conversion. |
| TXAKSAT1.TXT | This is the specificatons file that is read by the SimoZAPS Generation Function. The content of this file will be used by the preceding batch file to generate the COBOL source member that will do the specified file conversion. |
| TXAKSAC1.CBL | This is the generated COBOL source member that reads an ASCII/Text file and creates an ASCII, Indexed file. |
The following flowchart is a quick overview of the process for generating the COBOL source code to do the file conversion and formating.
|
The batch file for running the program to generate COBOL source code. | ||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|
|
|
Read the input file (TXAKSAT1) containing the specifications for generating the source code and create a new file (TXAKSAC1) containing the generated COBOL source code. | ||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
This section includes examples of programs that will update records within an existing Indexed file or VSAM keyed sequential data set. The sample programs will also add or insert new records.
Read a Sequential file with EBCDIC content and update or add records to an existing VSAM Keyed Sequential Data Set (KSDS) with EBCDIC content. This program is intended to run on a mainframe but will also run on a PC with Micro Focus Mainframe Express (it also runs with Net Express). This program does not convert the content of the records (i.e ASCII or EBCDIC) within the file.
This program randomly accesses the VSAM, Keyed-Sequential-Data-Set and will update an existing record or add a new record. The input file (EBCDIC content) does not need to be in sequence by the key-field.
The SQEKSE?2.ext files are used to generate the file conversion program.
| Member | Description |
| SQEKSEM2.BAT | This batch file will execute the SimoZAPS utility to create a COBOL program that will do the file conversion. |
| SQEKSET2.TXT | This is the specificatons file that is read by the SimoZAPS Generation Function. The content of this file will be used by the preceding batch file to generate the COBOL source member that will do the specified file conversion. |
| SQEKSEC2.CBL | This is the generated COBOL source member that reads anEBCDIC-Sequential file and updates an EBCDIC, VSAM, KSDS (or Indexed file). |
The following flowchart is a quick overview of the process for generating the COBOL source code to do the file conversion and formating.
|
The batch file for running the program to generate COBOL source code. | ||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|
|
|
Read the input file (SQEKSET2) containing the specifications for generating the source code and create a new file (SQEKSEC2) containing the generated COBOL source code. | ||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
This example will read a Text file with ASCII content and update an existing indexed file with ASCII content. This program was tested on the PC using Micro Focus Net Express. Since this program reads an ASCII/Text file (defined in the COBOL program as LINE SEQUENTIAL which is Micro Focus syntax) it will not run on the mainframe.
This program randomly accesses the Indexed file and will update an existing record or add a new record. The input file (ASCII/Text file) does not need to be in sequence by the key-field.
The TXAKSA?2.ext files are used to generate the file conversion program.
| Member | Description |
| TXAKSAM2.BAT | This batch file will execute the SimoZAPS utility to create a COBOL program that will do the file conversion. |
| TXAKSAT2.TXT | This is the specificatons file that is read by the SimoZAPS Generation Function. The content of this file will be used by the preceding batch file to generate the COBOL source member that will do the specified file conversion. |
| TXAKSAC2.CBL | This is the generated COBOL source member that reads an ASCII/Text file and updates an ASCII, VSAM, KSDS (or Indexed file). |
The following flowchart is a quick overview of the process for generating the COBOL source code to do the file conversion and formating.
|
The batch file for running the program to generate COBOL source code. | ||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|
|
|
Read the input file (TXAKSAT2) containing the specifications for generating the source code and create a new file (TXAKSAC2) containing the generated COBOL source code. | ||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
The following COBOL copy file (ASCEBCB1.CPY) contains the ASCII and EBCDIC tables. The tables may also be used to do case conversion.
*****************************************************************
* Copyright (C) 1987-2010 SimoTime Enterprises *
* All Rights Reserved *
*****************************************************************
*
*****************************************************************
* Provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
* The following tables are used by the INSPECT statement to do *
* the conversion betweeen EBCDIC and ASCII. *
* inspect FIELD-NAME converting EBCDIC-INFO to ASCII-INFO *
* inspect FIELD-NAME converting ASCII-INFO to EBCDIC-INFO *
* *
* The tables may also be used to convert between lower and *
* upper case. *
* inspect FIELD-NAME converting EBCDIC-LOWER to EBCDIC-UPPER *
* inspect FIELD-NAME converting ASCII-LOWER to ASCII-UPPER *
*****************************************************************
*
*> ------------------------------------------------------------
*> ** The EBCDIC Table ...
*> ** 01 A B C D E F G H I
*> ** 02 J K L M N O P Q R
*> ** 03 S T U V W X Y Z
*> ** 04 a b c d e f g h i
*> ** 05 j k l m n o p q r
*> ** 06 s t u v w x y z
*> ** 07 0 1 2 3 4 5 6 7 8 9
*> ** 08 space . < ( + | & ! $ *
*> ** 09 ) ; - / , % _ > ? `
*> ** 10 7D/7F Single/Double quote : # @7D =7F [ ] { }
*> ** 11 \ ~ ^
01 EBCDIC-DATA.
05 EBCDIC-UPPER-CASE-DATA.
10 filler pic X(9) value X'C1C2C3C4C5C6C7C8C9'.
10 filler pic X(9) value X'D1D2D3D4D5D6D7D8D9'.
10 filler pic X(8) value X'E2E3E4E5E6E7E8E9'.
05 EBCDIC-UPPER redefines EBCDIC-UPPER-CASE-DATA
pic X(26).
05 EBCDIC-LOWER-CASE-DATA.
10 filler pic X(9) value X'818283848586878889'.
10 filler pic X(9) value X'919293949596979899'.
10 filler pic X(8) value X'A2A3A4A5A6A7A8A9'.
05 EBCDIC-LOWER redefines EBCDIC-LOWER-CASE-DATA
pic X(26).
05 EBCDIC-DIGITS.
10 filler pic X(10) value X'F0F1F2F3F4F5F6F7F8F9'.
05 EBCDIC-SPECIAL.
10 filler pic X(10) value X'404B4C4D4E4F505A5B5C'.
10 filler pic X(10) value X'5D5E60616B6C6D6E6F79'.
10 filler pic X(10) value X'7A7B7C7D7E7FADBDC0D0'.
10 filler pic X(3) value X'E0A1B0'.
01 EBCDIC-INFO redefines EBCDIC-DATA pic X(95).
01 EBCDIC-TABLE redefines EBCDIC-DATA.
05 EBCDIC-BYTE pic X occurs 95 times.
*
*> ------------------------------------------------------------
*> ** The ASCII Table ...
*> ** 01 A B C D E F G H I
*> ** 02 J K L M N O P Q R
*> ** 03 S T U V W X Y Z
*> ** 04 a b c d e f g h i
*> ** 05 j k l m n o p q r
*> ** 06 s t u v w x y z
*> ** 07 0 1 2 3 4 5 6 7 8 9
*> ** 08 space . < ( + | & ! $ *
*> ** 09 ) ; - / , % _ > ? `
*> ** 10 27/22 Single/Double quote : # @27 =22 [ ] { }
*> ** 11 \ ~ ^
01 ASCII-DATA.
05 ASCII-UPPER-CASE-DATA.
10 filler pic X(9) value X'414243444546474849'.
10 filler pic X(9) value X'4A4B4C4D4E4F505152'.
10 filler pic X(8) value X'535455565758595A'.
05 ASCII-UPPER redefines ASCII-UPPER-CASE-DATA
pic X(26).
05 ASCII-LOWER-CASE-DATA.
10 filler pic X(9) value X'616263646566676869'.
10 filler pic X(9) value X'6A6B6C6D6E6F707172'.
10 filler pic X(8) value X'737475767778797A'.
05 ASCII-LOWER redefines ASCII-LOWER-CASE-DATA
pic X(26).
05 ASCII-DIGITS.
10 filler pic X(10) value X'30313233343536373839'.
05 ASCII-SPECIAL.
10 filler pic X(10) value X'202E3C282B7C2621242A'.
10 filler pic X(10) value X'293B2D2F2C255F3E3F79'.
10 filler pic X(10) value X'3A2340273D225B5D7B7D'.
10 filler pic X(3) value X'5C7E5E'.
01 ASCII-INFO redefines ASCII-DATA pic X(95).
01 ASCII-TABLE redefines ASCII-DATA.
05 ASCII-BYTE pic X occurs 95 times.
The purpose of this section is to provide a learning exercise that describes each of the conversion steps shown in the illustration at the beginning of this document. This section will start by creating an ASCII/Text file then do the following conversions. Each conversion step will use the previously created file to create a new file. The resulting ASCII/Text that is created in the final step should be identical to the original ASCII/Text file.
| Procedure | Description |
| BATTXAX1.BAT | Create an ASCII/Text file |
| TXAKSAX1.BAT | Convert ASCII/Text to ASCII/Indexed |
| KSASQEX1.BAT | Convert ASCII/Indexed to EBCDIC/Sequential |
| SQEKSEX1.BAT | Convert EBCDIC/Sequential to EBCDIC/VSAM/KSDS |
| KSESQEX1.BAT | Convert EBCDIC/VSAM/KSDS to EBCDIC/Sequential |
| SQEKSAX1.BAT | Convert EBCDIC/Sequential to ASCII/Indexed |
| KSATXAX1.BAT | Convert ASCII/Indexed to ASCII/Text |
How the conversion programs are created is discussed in previous sections of this document.
The following batch file (BATTXAX1.BAT) will create an ASCII/Text file (TXADB512.TXT).
@echo OFF
echo ****************************************************************
echo * This program is provided by: *
echo * SimoTime Enterprises, LLC *
echo * (C) Copyright 1987-2010 All Rights Reserved *
echo * Web Site URL: http://www.simotime.com *
echo * e-mail: helpdesk@simotime.com *
echo ****************************************************************
echo * BATTXAM1.BAT is STARTING...
echo * This process will create an ASCII/Text file by using the
echo * echo function to pipe data records from this batch file
echo * to the TXADB512.TXT file.
echo *
set txadb512=datasys2\txadb512.txt
echo * BATTXAM1.BAT is Piping records to TXADB512.TXT file...
echo 000000000123 COMP-3...... 000000000123 COMP........ 000000000123 Alphabet.... ABCDEFGHIJKLMONPQRSTUVWXYZ >%txadb512%
echo 000000000456 COMP-3...... 000000000456 COMP........ 000000000456 Alphabet.... ABCDEFGHIJKLMONPQRSTUVWXYZ >>%txadb512%
echo 000000000789 COMP-3...... 000000000789 COMP........ 000000000789 Alphabet.... ABCDEFGHIJKLMONPQRSTUVWXYZ >>%txadb512%
echo 000000001011 COMP-3...... 000000001011 COMP........ 000000001011 Alphabet.... ABCDEFGHIJKLMONPQRSTUVWXYZ >>%txadb512%
echo 000000001213 COMP-3...... 000000001213 COMP........ 000000001213 Alphabet.... ABCDEFGHIJKLMONPQRSTUVWXYZ >>%txadb512%
echo 000000001415 COMP-3...... 000000001415 COMP........ 000000001415 Alphabet.... ABCDEFGHIJKLMONPQRSTUVWXYZ >>%txadb512%
echo 000000001617 COMP-3...... 000000001617 COMP........ 000000001617 Alphabet.... ABCDEFGHIJKLMONPQRSTUVWXYZ >>%txadb512%
echo 000000001819 COMP-3...... 000000001819 COMP........ 000000001819 Alphabet.... ABCDEFGHIJKLMONPQRSTUVWXYZ >>%txadb512%
echo 000000002021 COMP-3...... 000000002021 COMP........ 000000002021 Alphabet.... ABCDEFGHIJKLMONPQRSTUVWXYZ >>%txadb512%
echo 000000002223 COMP-3...... 000000002223 COMP........ 000000002223 Alphabet.... ABCDEFGHIJKLMONPQRSTUVWXYZ >>%txadb512%
echo * BATTXAM1.BAT is COMPLETE...
The following batch file (TXAKSAX1.BAT) will create an ASCII/Text file (KSADB512.DAT and KSADB512.IDX).
@echo OFF
echo ****************************************************************
echo * This program is provided by: *
echo * SimoTime Enterprises, LLC *
echo * (C) Copyright 1987-2010 All Rights Reserved *
echo * Web Site URL: http://www.simotime.com *
echo * e-mail: helpdesk@simotime.com *
echo ****************************************************************
echo * TXAKSAX1.BAT is STARTING...
echo * This process will create an ASCII/Indexed file.
echo * Read TXADB512.TXT, the ASCII/Text file.
echo * Write TXADB512.DAT, the ASCII/Indexed file.
echo *
if "%ENV4ST01%" == "YES" goto :SKIPENV
CALL zENVst01.bat
:SKIPENV
set txadb512=datasys2\txadb512.txt
set ksadb512=datasys2\ksadb512.dat
rem *
run txaksac1
echo * TXAKSAX1.BAT is COMPLETE...
To generate or view the COBOL source code for the preceding process refer to Step A1 at the beginning of this document.
The following batch file (KSASQEX1.BAT) will create an EBCDIC Sequential file (SQEDB512.DAT).
@echo OFF
echo ****************************************************************
echo * This program is provided by: *
echo * SimoTime Enterprises, LLC *
echo * (C) Copyright 1987-2010 All Rights Reserved *
echo * Web Site URL: http://www.simotime.com *
echo * e-mail: helpdesk@simotime.com *
echo ****************************************************************
echo * KSASQEX1.BAT is STARTING...
echo * This process will create an EBCDIC/Sequential file.
echo * Read KSADB512.DAT, the ASCII/Indexed file.
echo * Write SQEDB512.DAT, the EBCDIC/Sequential file.
echo *
if "%ENV4ST01%" == "YES" goto :SKIPENV
CALL zENVst01.bat
:SKIPENV
set ksadb512=datasys2\ksadb512.dat
set sqedb512=datasys2\sqedb512.dat
rem *
run ksasqec1
echo * KSASQEX1.BAT is COMPLETE...
To generate or view the COBOL source code for the preceding process refer to Step 4 at the beginning of this document.
The following batch file (SQEKSEX1.BAT) will create an EBCDIC VSAM Keyed Sequential Data Set (KSEDB512.DAT and KSEDB512.IDX).
@echo OFF
echo ****************************************************************
echo * This program is provided by: *
echo * SimoTime Enterprises, LLC *
echo * (C) Copyright 1987-2010 All Rights Reserved *
echo * Web Site URL: http://www.simotime.com *
echo * e-mail: helpdesk@simotime.com *
echo ****************************************************************
echo * SQEKSEX1.BAT is STARTING...
echo * This process will create an EBCDIC/VSAM/KSDS.
echo * Read SEQDB512.DAT, the EBCDIC/Sequential file.
echo * Write KSEDB512.DAT, the EBCDIC/VSAM/KSDS.
echo *
if "%ENV4ST01%" == "YES" goto :SKIPENV
CALL zENVst01.bat
:SKIPENV
set sqedb512=datasys2\sqedb512.dat
set ksedb512=datasys2\ksedb512.dat
rem *
run sqeksec1
echo * SQEKSEX1.BAT is COMPLETE...
To generate or view the COBOL source code for the preceding process refer to Step 6 at the beginning of this document.
The following batch file (KSESQEX1.BAT) will create an EBCDIC Sequential File(SQEDB512.DAT).
@echo OFF
echo ****************************************************************
echo * This program is provided by: *
echo * SimoTime Enterprises, LLC *
echo * (C) Copyright 1987-2010 All Rights Reserved *
echo * Web Site URL: http://www.simotime.com *
echo * e-mail: helpdesk@simotime.com *
echo ****************************************************************
echo * KSESQEX1.BAT is STARTING...
echo * This process will create an EBCDIC/Sequential file
echo * Read KSEDB512.DAT, the EBCDIC/VSAM/KSDS.
echo * Write SQEDB512.DAT, the EBCDIC/Sequential file.
echo *
if "%ENV4ST01%" == "YES" goto :SKIPENV
CALL zENVst01.bat
:SKIPENV
set ksedb512=datasys2\ksedb512.dat
set sqedb512=datasys1\sqedb512.dat
rem *
run ksesqec1
echo * KSESQEX1.BAT is STARTING...
To generate or view the COBOL source code for the preceding process refer to Step 1 at the beginning of this document.
The following batch file (SQEKSAX1.BAT) will create an EBCDIC Sequential File(KSADB512.DAT and KSADB512.IDX).
@echo OFF
echo ****************************************************************
echo * This program is provided by: *
echo * SimoTime Enterprises, LLC *
echo * (C) Copyright 1987-2010 All Rights Reserved *
echo * Web Site URL: http://www.simotime.com *
echo * e-mail: helpdesk@simotime.com *
echo ****************************************************************
echo * SQEKSAX1.BAT is STARTING...
echo * This process will create an ASCII/Indexed file.
echo * Read SQEDB512.DAT, the EBCDIC/Sequential file.
echo * Write KSADB512.DAT, the ASCII/Indexed file.
echo *
if "%ENV4ST01%" == "YES" goto :SKIPENV
CALL zENVst01.bat
:SKIPENV
set sqedb512=datasys1\sqedb512.dat
set ksadb512=datasys1\ksadb512.dat
rem *
run sqeksac1
echo * SQEKSAX1.BAT is COMPLETE...
To generate or view the COBOL source code for the preceding process refer to Step 3 at the beginning of this document.
The following batch file (KSATXAX1.BAT) will create an ASCII/Text File(TXADB12.TXT).
@echo OFF
echo ****************************************************************
echo * This program is provided by: *
echo * SimoTime Enterprises, LLC *
echo * (C) Copyright 1987-2010 All Rights Reserved *
echo * Web Site URL: http://www.simotime.com *
echo * e-mail: helpdesk@simotime.com *
echo ****************************************************************
echo * KSATXAX1.BAT is STARTING...
echo * This process will create an ASCII/Text file.
echo * Read KSADB512.DAT, the ASCII/Indexed file.
echo * Write TXADB512.TXT, the ASCII/Text file.
echo *
if "%ENV4ST01%" == "YES" goto :SKIPENV
CALL zENVst01.bat
:SKIPENV
set ksadb512=datasys1\ksadb512.dat
set txadb512=datasys1\txadb512.txt
rem *
run ksatxac1
echo * KSATXAX1.BAT is COMPLETE...
To generate or view the COBOL source code for the preceding process refer to Step A1 at the beginning of this document.
The purpose of this document is to assist as a tutorial for new programmers or as a quick reference for experienced programmers. These sample programs are made available on an "as-is" basis and may be downloaded, copied and modified for specific situations as long as the copyright information is not removed or changed. As always, it is the programmer's responsibility to thoroughly test all programs.
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 any 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.
If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com
You may download this example at http://www.simotime.com/sim4dzip.htm#COBOLFileConversionV2Zip
Please view the complete list of SimoTime Z-Pack Examples at http://www.simotime.com/sim4dzip.htm.
Note: You must be attached to the Internet to download a Z-Pack or view the list.
The File Conversion, Volume 1 suite of programs includes a number of examples for file conversions that are required when migrating data between the PC and an IBM mainframe. Simply click on the following items to download this suite of sample source code.
The SimoZAPS Utility Program runs on a Windows platform and has the capability of generating a COBOL program that will do the conversion of sequential and VSAM (KSDS) files between EBCDIC and ASCII. SimoZAPS can also read a sequential file in EBCDIC format and create an ASCII/CRLF file or VSAM Keyed Sequential Data Set in ASCII format. The conversion tables may be viewed or modified to meet unique requirements. The HexCess function of SimoZAPS provides the capability of viewing, finding or patching the contents of a file in hexadecimal.
Check out The COBOL Connection in the SimoTime Library for more examples of mainframe COBOL techniques and sample code.
Check out The VSAM-QSAM Connection in the SimoTime Library for more examples of mainframe techniques and sample code for accessing VSAM and Sequential files.
This document provides a quick summary of the File Status Key for VSAM data sets and QSAM files. The File Status Key is a two character data item. The first character of the status key is known as status key 1; the second character is known as status key 2.
Take a look at the Table of ASCII, EBCDIC and Binary values.
To review all the information available on this site start at The SimoTime Home Page.
If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com.
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 |
| Version 05.03.26 |