Byte-Stream I/O
SimoBSIO - The COBOL Source Code
  Table of Contents  v-16.01.01 - simobsio.htm 
  Introduction
  SimoBSIO, What It Does
  SimoBSIO, How To Use
  The COBOL Source Code
  The COBOL Copy File
  Summary
  Software Agreement and Disclaimer
  Downloads and Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Comments or Feedback
  Company Overview
The SimoTime Home Page 

Table of Contents Previous Section Next Section Introduction

This program provides the programmer with the ability to access a file using Byte Stream I/O. This is commonly referred to as the "BSIO" module.

For an example of a program that calls this routine refer to the Current Server or Internet Access section of this document.

This document provides a listing of the COBOL source code for the callable routine SimoBSIO. SimoBSIO is a callable routine that uses the Micro Focus Byte-Stream I/O capability to access a file. This routine may access a single byte or multiple bytes of data at the specified offset into the file. SimoBSIO is written and tested using the Micro Focus COBOL dialect (it will only execute in a Micro Focus environment, it will not compile and run on a mainframe system).

Additional information about this program may be obtained by sending an e-mail to: helpdesk@simotime.com


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-2019
SimoTime Technologies and Services
All Rights Reserved

Table of Contents Previous Section Next Section SimoBSIO, What It Does

The SimoBSIO routine (or callable program) will provide access to a file at the byte level. The routine may access a single byte or multiple bytes in a single access.

Table of Contents Previous Section Next Section SimoBSIO, How To Use

The SIMOBSIO Member is a callable subroutine the processes a data file at the "BYTE I/O" level. To process a file it must first be opened. The following will OPEN the file.

           move 'C:\MYFILE.DAT' to PSIO-FILENAME
           move 'OPEN    ' to PSIO-REQUEST
           call 'SIMOBSIO' using PSIO-PASS-AREA

The following will READ a 10 byte string of data starting at offset zero. Since the file name was established during the OPEN request it should still be available in the pass area.

           move 'READ    ' to PSIO-REQUEST
           move ZERO to PSIO-OFFSET
           move 10 to PSIO-LENGTH
           call 'SIMOBSIO' using PSIO-PASS-AREA

The following will CLOSE the file. Since the file name was established during the OPEN request it should still be available in the pass area.

           move 'CLOSE   ' to PSIO-REQUEST
           call 'SIMOBSIO' using PSIO-PASS-AREA

The following is a list of the parameters that are required by the byte-stream I/O routine.

A COBOL Copy File is provided that defines the structure and size of this pass area.

Parameter Description
PSIO-REQUEST This parameter identifies the request of the calling program or the function to be performed by the byte-stream I/O routine. Refer to the next table for a list of possible keywords to be used when making a request.
PSIO-RETURN This parameter is modified by the SimoBSIO routine. A zero (0) value indicates a successful completion of the request. A non-zero value indicates an invalid request, an end-of-file condition or an error condition.
PSIO-FILENAME This parameter must be provided by the calling routine. It should contain the physical name of the file to be accessed.
PSIO-FILE-SIZE This parameter is modified by the SimoBSIO routine after the initial call that opens the file. The value will be the size of the file in bytes.
PSIO-OFFSET This parameter must be provided by the calling routine and is the offset into the file where the requested access will begin.
PSIO-LENGTH This parameter must be provided by the calling routine and is the length or number of bytes to be accessed..
PSIO-MAX-SIZE This parameter must be provided by the calling routine and is the maximum size of the buffer that holds the data string that will be accessed.
PSIO-BUFFER This is the data buffer. For a write or update it must be provided by the calling program. For a read it will be modified by SimoBSIO and contain the text string that was read from the file.
  A List of the Parameters that are Required to use the Byte-Stream I/O

The following is a list of the keywords used in the (PSIO-REQUEST) field of the pass area that is used by a program making a call to SIMOBSIO.

Parameter Possible Keywords for PSIO-REQUEST
64BITOFF This request will disable the support for very large files. The maximum file size will be limited to four (4) gigabytes.
64BITON This is the default value. This provides support for very large files. Files may be larger than four (4) gigabytes.
CLOSE This request will close the file for read only. PSIO-FILENAME must contain a valid file name. If the CLOSE request is successful the PSIO-RETURN will contain a ZERO value. If unsuccessful a non-ZERO value is returned.
CREATE WIP
FILEINFO WIP
OPEN This request will open the file for read only. PSIO-FILENAME must contain a valid file name. If the OPEN request is successful the PSIO-RETURN will contain a ZERO value. If unsuccessful a non-ZERO value is returned.
OPENPUT This request will open the file for write only. PSIO-FILENAME must contain a valid file name. If the WRITE request is successful the PSIO-RETURN will contain a ZERO value. If unsuccessful a non-ZERO value is returned.
READ This request will read from the file starting at the offset (PSIO-OFFSET) value for the number of bytes specified by the length (PSIO-LENGTH) value.
WRITE This request will write to the file starting at the offset (PSIO-OFFSET) value for the number of bytes specified by the length (PSIO-LENGTH) value.
  A List of Keywords for the PSIO-REQUEST Field

Table of Contents Previous Section Next Section The COBOL Source Code

The following (SIMOBSIO.cbl) is the COBOL Source Code.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    SIMOBSIO.
       AUTHOR.        SIMOTIME TECHNOLOGIES.
      *****************************************************************
      * Copyright (C) 1987-2019 SimoTime Technologies.                *
      *                                                               *
      * All rights reserved.  Unpublished, all rights reserved under  *
      * copyright law and international treaty.  Use of a copyright   *
      * notice is precautionary only and does not imply publication   *
      * or disclosure.                                                *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Technologies. 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           *
      * Technologies.                                                 *
      *                                                               *
      * Permission to use, copy and modify 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           *
      * Technologies.                                                 *
      *                                                               *
      * SimoTime Technologies makes no warranty or representations    *
      * about the suitability of the software 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                                  *
      *                                                               *
      * SimoTime Technologies                                         *
      * 15 Carnoustie Drive                                           *
      * Novato, CA 94949-5849                                         *
      * 415.883.6565                                                  *
      *                                                               *
      * RESTRICTED RIGHTS LEGEND                                      *
      * Use, duplication, or disclosure by the Government is subject  *
      * to restrictions as set forth in subparagraph (c)(1)(ii) of    *
      * the Rights in Technical Data and Computer Software clause at  *
      * DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of          *
      * Commercial  Computer Software - Restricted Rights  at 48      *
      * CFR 52.227-19, as applicable.  Contact SimoTime Technologies, *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *****************************************************************
      *
      * Source Module: SIMOBSIO.CBL
      *
      * CALL Interface
      * ------------
      * call 'SIMOBSIO' using PSIO-PASS-AREA
      *
      * DESCRIPTION
      * -----------
      * This callable program uses the Byte-Stream I/O capabilities
      * provided by Micro Focus to acces a file by reading a single
      * byte or multiple bytes based on the caller's request.
      *
      * MAINTENANCE
      * -----------
      * 04/27/1992 Provided by SimoTime Technologie
      *
      *****************************************************************
      *
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  SIM-TITLE.
           05  T1 pic X(11) value '* SIMOBSIO '.
           05  T2 pic X(34) value 'Byte-Stream File I/O Routine      '.
           05  T3 pic X(10) value ' v16.06.15'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* SIMOBSIO '.
           05  C2 pic X(20) value 'Copyright 1987-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           05  C4 pic X(20) value ' All Rights Reserved'.

      *****************************************************************
      *    Data-structure for byte stream files...
      *****************************************************************
      *    Byte Stream Files                                          *
      *    -----------------                                          *
      *    For all the routines the RETURN-CODE register is set to    *
      *    zero if the routine is successful.                         *
      *****************************************************************
      *    Open a file, Byte Stream File...
      *    filename         space or null terminated
      *    access-mode    01=read only
      *                   02=write only, deny-mode must=0
      *                   03=read/write
      *                   When the x'40' bit is on then large file
      *                   access is enabled (larger than 4-gig)
      *                   65=read only
      *                   66=write only, deny-mode must=0
      *                   67=read/write
      *    deny-mode      0=deny read/write(exclusive)
      *                   1=deny write
      *                   2=deny read
      *                   3=deny neither read nor write
      *    device           future use, must=0
      *    file-handle      if succesful open
      *    ------------------------------------------------------------
      *
       01  BSIO-FILENAME               pic X(256)   value SPACES.
       01  BSIO-ACCESS-MODE            pic X        comp-x  value 1.
       01  BSIO-DENY-MODE              pic X        comp-x  value 0.
       01  BSIO-DEVICE                 pic X        comp-x  value 0.
       01  BSIO-FILE-HANDLE            pic X(4)     value LOW-VALUES.
       01  BSIO-FILE-OFFSET            pic X(8)     comp-x  value 1.
       01  BSIO-FILE-COUNT             pic X(4)     comp-x  value 1.
       01  BSIO-FLAGS                  pic X        comp-x  value 0.
       01  BSIO-BUFFER                 pic X(32760) value SPACES.

      *    One of the following must be moved to BSIO-ACCESS-MODE.
      *    Standard, File size < 4 gigabytes.
       01  BSIO-S-READ                 pic X        comp-x  value 1.
       01  BSIO-S-WRITE                pic X        comp-x  value 2.
       01  BSIO-S-READ-WRITE           pic X        comp-x  value 3.
      *    Extended, File size = or > 4 gigabytes.
       01  BSIO-X-READ                 pic X        comp-x  value 65.
       01  BSIO-X-WRITE                pic X        comp-x  value 66.
       01  BSIO-X-READ-WRITE           pic X        comp-x  value 67.
      *    Deny Mode.
       01  BSIO-X-DENY-NEITHER         pic X        comp-x  value 3.
       01  BSIO-X-DENY-READ            pic X        comp-x  value 2.
       01  BSIO-X-DENY-WRITE           pic X        comp-x  value 1.
       01  BSIO-X-DENY-READ-WRITE      pic X        comp-x  value 0.

       01  BIG-FILE-SUPPORT            pic X        value 'Y'.

      *****************************************************************
      * Data structure for message display and logging...             *
      *****************************************************************
       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* SIMOBSIO '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(068)  value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

       01  FIRST-TIME                  pic X       value 'Y'.

       01  IO-STATUS.
           05  IO-STAT1            pic X.
           05  IO-STAT2            pic X.
       01  TWO-BYTES.
           05  TWO-BYTES-LEFT      pic X.
           05  TWO-BYTES-RIGHT     pic X.
       01  TWO-BYTES-BINARY        redefines TWO-BYTES pic 9(4) comp.

      *****************************************************************
       LINKAGE SECTION.
       COPY PASSBSIO.

      *****************************************************************
       PROCEDURE DIVISION using PSIO-PASS-AREA.
           if  FIRST-TIME = 'Y'
               perform Z-POST-COPYRIGHT
               move 'N' to FIRST-TIME
           end-if

      *    Set Access-Mode to Read-Only...
           add 1 to ZERO giving BSIO-ACCESS-MODE
           evaluate PSIO-REQUEST
               when 'READBSIO' perform BSIOX-FILE-READBSIO
               when 'OPEN    ' perform BSIOX-FILE-OPEN
               when 'OPENPUT ' perform BSIOX-FILE-OPEN-PUT
               when 'OPENI-O ' perform BSIOX-FILE-OPEN-I-O
               when 'FILEINFO' perform BSIOX-GET-FILE-INFO
               when 'CLOSE   ' perform BSIOX-FILE-CLOSE
               when 'WRITE   ' perform BSIOX-FILE-WRITE
               when 'CREATE  ' perform BSIOX-FILE-CREATE
               when '64BITON ' move 'Y' to BIG-FILE-SUPPORT
                               move ZERO to RETURN-CODE
                               move ZERO to PSIO-RETURN
               when '64BITOFF' move 'N' to BIG-FILE-SUPPORT
                               move ZERO to RETURN-CODE
                               move ZERO to PSIO-RETURN
               when 'INIT    ' perform BSIOX-FILE-INIT
               when 'OPENREAD' perform BSIOX-FILE-OPEN-READ
               when other      perform ABEND-QUIT
           end-evaluate

      *    add RETURN-CODE to ZERO giving PSIO-RETURN

           if  PSIO-RETURN not = ZERO
               perform BSIOX-FILE-CLOSE
           end-if

           GOBACK.

      *****************************************************************
      *    Do an Abnormal termination of the program...
      *****************************************************************
       ABEND-QUIT.
           if  MESSAGE-TEXT not = SPACES
               perform Z-DISPLAY-CONSOLE-MESSAGE
           end-if
           move 'Program return-to-caller with ABEND'
             to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE
           add 16 to ZERO giving RETURN-CODE
           add RETURN-CODE to ZERO giving PSIO-RETURN
           GOBACK
           exit.

      *****************************************************************
       BSIOX-FILE-READBSIO.
           subtract BSIO-FLAGS from BSIO-FLAGS   *> normal read
           add PSIO-OFFSET to ZERO giving BSIO-FILE-OFFSET
           if  PSIO-LENGTH > PSIO-MAX-SIZE
               add PSIO-MAX-SIZE to zero giving BSIO-FILE-COUNT
               move 'ERROR, Short READ, Requested length exceeds MAX'
                 to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
           else
               add PSIO-LENGTH to zero giving BSIO-FILE-COUNT
           end-if
           perform BSIO-READ
           if  RETURN-CODE = 0
               move BSIO-BUFFER to PSIO-BUFFER
               move ZERO to PSIO-RETURN
           else
               if  RETURN-CODE = 12592
                   add 10 to ZERO giving RETURN-CODE
               end-if
               add RETURN-CODE to ZERO giving PSIO-RETURN
      *        display RETURN-CODE
               if  RETURN-CODE = 10
                   add RETURN-CODE to ZERO giving PSIO-RETURN
                   move SPACES to PSIO-BUFFER
                   move "End of File..."  to MESSAGE-TEXT
                   perform Z-DISPLAY-CONSOLE-MESSAGE
               else
                   move "Error during file READ..."  to MESSAGE-TEXT
                   perform Z-DISPLAY-CONSOLE-MESSAGE
                   add RETURN-CODE to ZERO giving TWO-BYTES-BINARY
                   move TWO-BYTES to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform ABEND-QUIT
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       BSIOX-FILE-INIT.
           move ZEROES to PSIO-RETURN
           move SPACES to PSIO-FILENAME
           move ZEROES to PSIO-FILE-SIZE
           move ZEROES to PSIO-OFFSET
           move ZEROES to PSIO-LENGTH
           move ZEROES to PSIO-MAX-SIZE
           move SPACES to PSIO-BUFFER
           exit.
      *---------------------------------------------------------------*
       BSIOX-FILE-OPEN-READ.
           add BSIO-X-DENY-NEITHER to ZERO giving BSIO-DENY-MODE
           perform BSIOX-FILE-OPEN
           exit.
      *---------------------------------------------------------------*
       BSIOX-FILE-OPEN.
           move PSIO-FILENAME to BSIO-FILENAME
           if  BIG-FILE-SUPPORT = 'N'
               add BSIO-S-READ to ZERO giving BSIO-ACCESS-MODE
           else
               add BSIO-X-READ to ZERO giving BSIO-ACCESS-MODE
           end-if
      *    display BSIO-FILENAME
           perform BSIO-OPEN
           if  RETURN-CODE = 0
               add RETURN-CODE to ZERO giving PSIO-RETURN
           else
               move "Error during file OPEN..."  to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               add RETURN-CODE to ZERO giving TWO-BYTES-BINARY
               move TWO-BYTES to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform ABEND-QUIT
           end-if
           exit.
      *---------------------------------------------------------------*
       BSIOX-FILE-CREATE.
           move PSIO-FILENAME to BSIO-FILENAME
           if  BIG-FILE-SUPPORT = 'N'
               add BSIO-S-WRITE to ZERO giving BSIO-ACCESS-MODE
           else
               add BSIO-X-WRITE to ZERO giving BSIO-ACCESS-MODE
           end-if
      *    display BSIO-FILENAME
           perform BSIO-CREATE
           if  RETURN-CODE = 0
               add RETURN-CODE to ZERO giving PSIO-RETURN
           else
               move "Error during file CREATE..."  to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               add RETURN-CODE to ZERO giving TWO-BYTES-BINARY
               move TWO-BYTES to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               move PSIO-FILENAME to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               perform ABEND-QUIT
           end-if
           exit.
      *---------------------------------------------------------------*
       BSIOX-FILE-OPEN-PUT.
           move PSIO-FILENAME to BSIO-FILENAME
           if  BIG-FILE-SUPPORT = 'N'
               add BSIO-S-WRITE to ZERO giving BSIO-ACCESS-MODE
           else
               add BSIO-X-WRITE to ZERO giving BSIO-ACCESS-MODE
           end-if
      *    display BSIO-FILENAME
           perform BSIO-OPEN
           if  RETURN-CODE = 0
               add RETURN-CODE to ZERO giving PSIO-RETURN
           else
               move "Error during file OPENPUT..."  to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               add RETURN-CODE to ZERO giving TWO-BYTES-BINARY
               move TWO-BYTES to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform ABEND-QUIT
           end-if
           exit.
      *---------------------------------------------------------------*
       BSIOX-FILE-OPEN-I-O.
           move PSIO-FILENAME to BSIO-FILENAME
           if  BIG-FILE-SUPPORT = 'N'
               add BSIO-S-READ-WRITE to ZERO giving BSIO-ACCESS-MODE
           else
               add BSIO-X-READ-WRITE to ZERO giving BSIO-ACCESS-MODE
           end-if
      *    display BSIO-FILENAME
           perform BSIO-OPEN
           if  RETURN-CODE = 0
               add RETURN-CODE to ZERO giving PSIO-RETURN
           else
               move "Error during file OPENI-O..."  to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               add RETURN-CODE to ZERO giving TWO-BYTES-BINARY
               move TWO-BYTES to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform ABEND-QUIT
           end-if
           exit.
      *---------------------------------------------------------------*
       BSIOX-FILE-CLOSE.
           perform BSIO-CLOSE
           if  RETURN-CODE = 0
               if  PSIO-RETURN not = 10
                   add RETURN-CODE to ZERO giving PSIO-RETURN
               end-if
           else
               move "Error during file CLOSE..."  to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               add RETURN-CODE to ZERO giving TWO-BYTES-BINARY
               move TWO-BYTES to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform ABEND-QUIT
           end-if
           exit.
      *---------------------------------------------------------------*
       BSIOX-FILE-WRITE.
           subtract BSIO-FLAGS from BSIO-FLAGS
           add PSIO-OFFSET to ZERO giving BSIO-FILE-OFFSET
           if  PSIO-LENGTH > PSIO-MAX-SIZE
               add PSIO-MAX-SIZE to zero giving BSIO-FILE-COUNT
               move 'ERROR, Short WRITE, Requested length exceeds MAX'
                 to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
           else
               add PSIO-LENGTH to zero giving BSIO-FILE-COUNT
           end-if
           move PSIO-BUFFER to BSIO-BUFFER
           perform BSIO-WRITE
           if  RETURN-CODE = 0
               add RETURN-CODE to ZERO giving PSIO-RETURN
               move BSIO-BUFFER to PSIO-BUFFER
           else
               move "Error during file WRITE..."  to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               add RETURN-CODE to ZERO giving TWO-BYTES-BINARY
               move TWO-BYTES to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform ABEND-QUIT
           end-if
           exit.
      *---------------------------------------------------------------*
       BSIOX-GET-FILE-INFO.
      *    Get file size into BSIO-FILE-OFFSET
           subtract BSIO-FLAGS from BSIO-FLAGS
           add      128          to BSIO-FLAGS

           perform BSIO-READ
           if  RETURN-CODE = 0
               add RETURN-CODE to ZERO giving PSIO-RETURN
           else
               move "Error during file READ..."  to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               add RETURN-CODE to ZERO giving TWO-BYTES-BINARY
               move TWO-BYTES to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform ABEND-QUIT
           end-if
           add BSIO-FILE-OFFSET to ZERO giving PSIO-FILE-SIZE
           exit.
      *---------------------------------------------------------------*
      *    Byte Stream Files                                          *
      *    -----------------                                          *
      *    For all the routines the RETURN-CODE register is set to    *
      *    zero if the routine is successful.                         *
      *---------------------------------------------------------------*
      *    Open a file, Byte Stream File...                           *
      *                 filename         space or null terminated     *
      *                 access-mode    1=read only                    *
      *                                2=write only, deny-mode must=0 *
      *                                3=read/write                   *
      *                 deny-mode      0=deny read/write(exclusive)   *
      *                                1=deny write                   *
      *                                2=deny read                    *
      *                                3=deny neither read nor write  *
      *                 device           future use, must=0           *
      *                 file-handle      if succesful open            *
      *---------------------------------------------------------------*
       BSIO-OPEN.
           call "CBL_OPEN_FILE" using  BSIO-FILENAME
                                       BSIO-ACCESS-MODE
                                       BSIO-DENY-MODE
                                       BSIO-DEVICE
                                       BSIO-FILE-HANDLE
           exit.
      *---------------------------------------------------------------*
       BSIO-CREATE.
           call "CBL_CREATE_FILE" using  BSIO-FILENAME
                                         BSIO-ACCESS-MODE
                                         BSIO-DENY-MODE
                                         BSIO-DEVICE
                                         BSIO-FILE-HANDLE
           exit.
      *---------------------------------------------------------------*
      *    Read a file, Byte Stream File...                           *
      *                 file-handle      returned from open           *
      *                 file-offset      offset in file to start read *
      *                 file-count   nnn=bytes to read                *
      *                 flags          0=standard read                *
      *                              128=return size in file-offset   *
      *                 buffer           data buffer for read         *
      *---------------------------------------------------------------*
       BSIO-READ.
           call "CBL_READ_FILE" using  BSIO-FILE-HANDLE
                                       BSIO-FILE-OFFSET
                                       BSIO-FILE-COUNT
                                       BSIO-FLAGS
                                       BSIO-BUFFER
           exit.
      *---------------------------------------------------------------*
       BSIO-WRITE.
           call "CBL_WRITE_FILE" using BSIO-FILE-HANDLE
                                       BSIO-FILE-OFFSET
                                       BSIO-FILE-COUNT
                                       BSIO-FLAGS
                                       BSIO-BUFFER
           exit.
      *---------------------------------------------------------------*
       BSIO-CLOSE.
           call "CBL_CLOSE_FILE" using BSIO-FILE-HANDLE
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative tasks         *
      * 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-CONSOLE-MESSAGE
           end-if
           move 'PROGRAM-IS-ABENDING...'  to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE
           add 12 to ZERO giving RETURN-CODE
           STOP RUN
           exit.

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

      *****************************************************************
      * Display the file status bytes. This routine will display as   *
      * two digits if the full two byte file status is numeric. If    *
      * second byte is non-numeric then it will be treated as a       *
      * binary number.                                                *
      *****************************************************************
       Z-DISPLAY-IO-STATUS.
           if  IO-STATUS not NUMERIC
           or  IO-STAT1    = '9'
               subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
               move IO-STAT2 to TWO-BYTES-RIGHT
               display '* SIMOBSIO File-Status-' IO-STAT1 '/'
                       TWO-BYTES-BINARY upon console
           else
               display '* SIMOBSIO File-Status-' IO-STATUS upon console
           end-if
           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE     upon console
           display SIM-COPYRIGHT upon console
           exit.
      *****************************************************************
      *      This example is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Table of Contents Previous Section Next Section The COBOL Copy File

The following is the source code for the copy file (PASSBSIO.cpy) that defines the parameters used by the byte-stream I/O routine.

      *****************************************************************
      *    Pass Area for calling BSIORTN1                             *
      *****************************************************************
       01  PSIO-PASS-AREA.
           05  PSIO-REQUEST            pic X(8).
           05  PSIO-RETURN             pic 9(4).
           05  PSIO-FILENAME           pic X(256).
           05  PSIO-FILE-SIZE          pic 9(12).
           05  PSIO-OFFSET             pic 9(12).
           05  PSIO-LENGTH             pic 9(7).
           05  PSIO-MAX-SIZE           pic 9(7).
           05  PSIO-BUFFER             pic X(32760).
      *!   PASSBSIO - End-of-Copy File...

Table of Contents Previous Section Next Section Summary

This program provides the programmer with the ability to access a file using Byte Stream I/O. 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 document and the links to other documents are intended to provide a greater awareness of the Data Management and Application Processing alternatives.

The 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 send an e-mail to: helpdesk@simotime.com or call 415 883-6565. We appreciate hearing from you.

Table of Contents Previous Section Next Section 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.

Table of Contents Previous Section Next Section Downloads and Links

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.

Table of Contents Previous Section Next Section Current Server or Internet Access

The following links may be to the current server or to the Internet.

Note: The latest versions of the SimoTime Documents and Program Suites are available on the Internet and may be accessed using the Link to Internet icon. If a user has a SimoTime Enterprise License the Documents and Program Suites may be available on a local server and accessed using the Link to Server icon.

Link to Internet   Link to Server   Explore How to FTP (using BINARY mode) a File with Variable Length Records from a Mainframe System to a Windows System and then convert the Mainframe format to a Micro Focus format. The mainline program will call the SIMOVREC and SIMOBSIO modules that are available from SimoTime in a separate package.

Link to Internet   Link to Server   Explore a complete list of the SimoTime Callable Routines or Utility Programs. This includes the callable routines and utility programs for the Micro Focus environment.

Link to Internet   Link to Server   Explore An Enterprise System Model that describes and demonstrates how Applications that were running on a Mainframe System and non-relational data that was located on the Mainframe System were copied and deployed in a Microsoft Windows environment with Micro Focus Enterprise Server.

Link to Internet   Link to Server   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.

Link to Internet   Link to Server   Explore The File Status Return Codes to interpret the results of accessing VSAM data sets and/or QSAM files.

Table of Contents Previous Section Next Section Internet Access Required

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 and services available from Micro Focus. This link requires an Internet Connection.

Table of Contents Previous Section Next Section Glossary of Terms

Link to Internet   Link to Server   Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.

Table of Contents Previous Section Next Section Comments or Feedback

This document was created and is copyrighted and maintained by SimoTime Technologies.

If you have any questions, suggestions, comments or feedback please call at 1 415 827-7045 or send an e-mail to: helpdesk@simotime.com

We appreciate hearing from you.

Table of Contents Previous Section Next Section Company Overview

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 at 1 415 827-7045 or send an e-mail to: helpdesk@simotime.com

Also, check the web site at http://www.simotime.com


Return-to-Top
The COBOL Source Code for Byte-Stream I/O
Copyright © 1987-2019
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com