Record Sequential to ASCII/Text
 File Format Conversion
http://www.simotime.com
When technology complements business    Copyright © 1987-2010  SimoTime Enterprises  All Rights Reserved
  Table of Contents Version 10.03.20 
  Introduction
  CMD for Execution with Net Express and Windows
  The COBOL File Format Conversion Program
  Summary
 
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Glossary of Terms
  Comments or Suggestions
  About SimoTime

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

This sample program describes how to do a file-format conversion by reading an ASCII-encoded, record-sequential file and writing to a new ASCII-encoded, line-sequential file (or ASCII/Text file). The program was compiled using a Micro Focus dialect since it writes to a line sequential (or ASCII/Text) file. The program was generated using SimoTime technology.

CMD for Execution with Net Express and Windows
(Next) (Previous) (Table-of-Contents)

The following (R2L256E1.CMD) is a sample of the Windows CMD needed to run this job.

@echo OFF
rem  * *******************************************************************
rem  *                   This program is provided by:                    *
rem  *                    SimoTime Enterprises, LLC                      *
rem  *           (C) Copyright 1987-2010 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Read Record-Sequential, write ASCII/Text file.
rem  * Author - SimoTime Enterprises
rem  * Date   - January 24, 1996
rem  *
rem  * The job will read a Record Sequential File and write to a Line
rem  * Sequential file.
rem  *
rem  *    ************
rem  *    * R2L256E1 *
rem  *    ********cmd*
rem  *         *
rem  *         *
rem  *    ************     ************     ************
rem  *    * SimoEXEC ******* SIMOLOGS ******* CONSOLE  *
rem  *    ********cbl*  *  ********cbl*  *  ************
rem  *         *        *                *
rem  *         *        *                *  ************
rem  *         *        *                ****  SYSLOG  *
rem  *         *        *                   ********txt*
rem  *         *        *
rem  *         *        **************************
rem  *         *                                 *
rem  *         *           ************     ************     ************
rem  *         *           * Dat256RS ******* R2L256C1 ******* Dat256LS *
rem  *         *           ********dat*     ********cbl*     ********csv*
rem  *         *
rem  *    ************
rem  *    *   EOJ    *
rem  *    ************
rem  *
rem  * *******************************************************************
rem  * Step   1   Delete any previously created file...
rem  *
     call Env1PROD
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem  *
     call SimoNOTE "*******************************************************R2L256E1"
     call SimoNOTE "Starting JobName R2L256E1, User is %USERNAME%"
:DeleteQSAM
     call SimoNOTE "Identify JobStep DeleteQSAM"
     set Dat256RS=%BaseLib1%\DataLib1\DynA\SIMOTIME.DATA.CUSEXTSV.DAT
     set Dat256LS=%BaseLib1%\DataLib1\Wrk1\Dat25601.CSV
     if exist %Dat256LS% del %Dat256LS%
rem  *
rem  * *******************************************************************
rem  * Step   2   Edit input, create a new output file...
rem  *
:ExecuteFileFormatConversion
     call SimoNOTE "Identify JobStep ExecuteFileFormatConversion
     SimoEXEC EXEC R2L256C1
     if exist %Dat256LS% call SimoNOTE "Produced DataSet %Dat256LS%"
     call SimoNOTE "Finished JobName R2L256E1"
:End
     call SimoNOTE "Conclude SysLog is %SYSLOG%"
     if not "%1" == "nopause" pause

The COBOL File Format Conversion Program
(Next) (Previous) (Table-of-Contents)

The following (R2L256C1.CBL) is a sample of the Micro Focus COBOL demonstration program. This program will not compile or execute on an IBM Mainframe because of the ORGANIZATION IS LINE SEQUENTIAL on the SELECT statement. If the statement was changed to read ORGANIZATION IS SEQUENTIAL it would run on an IBM Mainframe and "read from" and "write to" a sequential file. The program was tested using Micro Focus Net Express, version 4.0 running on Windows/2000.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    R2L256C1.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      *           This program was generated by SimoZAPS              *
      *             A product of SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *  Generation Date: 2007-02-21  Generation Time: 09:38:55:12    *
      *                                                               *
      *                                   Record    Record     Key    *
      *  Function  Name     Organization  Format    Max-Min  Pos-Len  *
      *  INPUT     DAT256RS SEQUENTIAL    VARIABLE   00256            *
      *                                                               *
      *  OUTPUT    DAT256LS ASCII/CRLF    VARIABLE   00256            *
      *                                                               *
      *                                                               *
      *                Translation Mode is UNKNOWN                    *
      *                                                               *
      *****************************************************************
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT DAT256RS-FILE  ASSIGN TO       DAT256RS
                  ORGANIZATION  IS SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS DAT256RS-STATUS.
           SELECT DAT256LS-FILE  ASSIGN TO       DAT256LS
                  ORGANIZATION  IS LINE SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS DAT256LS-STATUS.

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

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

      *****************************************************************
      * This program was created using 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.                                          *
      *                                                               *
      * 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 additional information contact SimoTime Enterprises.      *
      *                                                               *
      *        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 '* R2L256C1 '.
           05  T2 pic X(34) value 'Data Migration and Conversion     '.
           05  T3 pic X(10) value 'v06.01.01 '.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* R2L256C1 '.
           05  C2 pic X(20) value 'Created by SimoZAPS,'.
           05  C3 pic X(20) value '  a utility package '.
           05  C4 pic X(28) value 'of SimoTime Enterprises, LLC'.

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

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

       01  DAT256RS-LRECL    pic 9(5)    value 00256.
       01  DAT256LS-LRECL    pic 9(5)    value 00256.

      *****************************************************************
      * 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(11)   value '* R2L256C1 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

      *****************************************************************
       01  PROGRAM-NAME            pic X(8)     value 'R2L256C1'.

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

       01  DAT256RS-TOTAL.
           05  DAT256RS-RDR  pic 9(9)    value 0.
           05  filler      pic X(3)    value ' - '.
           05  filler      pic X(23)   value 'Line count for DAT256RS'.
       01  DAT256LS-TOTAL.
           05  DAT256LS-ADD  pic 9(9)    value 0.
           05  filler      pic X(3)    value ' - '.
           05  filler      pic X(23)   value 'Line count for DAT256LS'.


      *****************************************************************
       PROCEDURE DIVISION.
           perform Z-POST-COPYRIGHT
           perform DAT256RS-OPEN
           perform DAT256LS-OPEN

           perform until DAT256RS-STATUS not = '00'
               perform DAT256RS-READ
               if  DAT256RS-STATUS = '00'
                   add 1 to DAT256RS-RDR
                   perform BUILD-OUTPUT-RECORD
                   perform DAT256LS-WRITE
                   if  DAT256LS-STATUS = '00'
                       add 1 to DAT256LS-ADD
                   end-if
               end-if
           end-perform

           move DAT256RS-TOTAL to MESSAGE-TEXT
           perform Z-DISPLAY-MESSAGE-TEXT

           move DAT256LS-TOTAL to MESSAGE-TEXT
           perform Z-DISPLAY-MESSAGE-TEXT

           if  APPL-EOF
               move 'is Complete...' to MESSAGE-TEXT
           else
               move 'is ABENDING...' to MESSAGE-TEXT
           end-if
           perform Z-DISPLAY-MESSAGE-TEXT

           perform DAT256LS-CLOSE
           perform DAT256RS-CLOSE
           GOBACK.

      *****************************************************************
       BUILD-OUTPUT-RECORD.
      *>   TransCOPY...
           move DAT256RS-REC(00001:00256) to DAT256LS-REC(00001:00256)
           exit.

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

      *****************************************************************
      * I/O Routines for the OUTPUT File...                           *
      *****************************************************************
       DAT256LS-WRITE.
           if  DAT256LS-OPEN-FLAG = 'C'
               perform DAT256LS-OPEN
           end-if
           write DAT256LS-REC
           if  DAT256LS-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  DAT256LS-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 DAT256LS' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move DAT256LS-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       DAT256LS-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open OUTPUT DAT256LS-FILE
           if  DAT256LS-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to DAT256LS-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with DAT256LS' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move DAT256LS-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       DAT256LS-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close DAT256LS-FILE
           if  DAT256LS-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'C' to DAT256LS-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with DAT256LS' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move DAT256LS-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.

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

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

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE
           display SIM-COPYRIGHT
           exit.
      *****************************************************************
      *           This program was generated by SimoZAPS              *
      *             A product of SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *  Generation Date: 2007-02-21  Generation Time: 09:38:55:12    *
      *****************************************************************

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

The purpose of this program is to provide an example of file-format conversion by reading a record-sequential file and creating a line-sequential file..

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

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

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

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

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

This suite of programs is part of the File Maintenance package for the Customer Master File and the Item Master File.

File Name  Link for download information
CUSTMAST  http://www.simotime.com/sim4dzip.htm#cumast01  is for the Customer Master File
ITEMMAST  http://www.simotime.com/sim4dzip.htm#itmast01  is for the Item Master File

You may view the complete list of SimoTime 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 SimoZAPS Utility Program has the capability of generating a COBOL program that will do the conversion of sequential and VSAM (KSDS) files between EBCDIC and ASCII. 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.

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

Check out  The VSAM - QSAM Connection  for more examples of mainframe VSAM and QSAM accessing techniques and sample code.

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

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

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

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

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

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

We appreciate your comments and feedback.

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

Founded in 1987, SimoTime Enterprises is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complimentary 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 06.11.01