|
Write, Line Sequential SIMOPL4K - 4K Maximum Record Length |
![]() |
| The SimoTime Home Page |
This document provides a listing of the COBOL source code for a callable routine that provides write access to a Line Sequential (or ASCII/Text) file.
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-2024
SimoTime Technologies and Services
All Rights Reserved
The SIMOPL4K program provides an easy to use, callable routine for writing variable-length records to a Line Sequential file with a maximum record length of 4096-bytes.
First, the pass area (or data structure) must be defined in the WORKING-STORAGE section of the program that will call SIMOPL4K. A COBOL copy file is provided for this purpose and the same copy file is used in the LINKAGE section of SIMOPL4K.
COPY PASSPL4K.
Next, the data items in the pass area need to be initialized prior to calling SIMOPL4K.
move 'OPEN' to PA-PL4K-REQUEST
Move '0000' to PA-PL4K-RESPOND
move SPACES to PA-PL4K-STORAGE
Next, the following shows the line of code that makes the call to SIMOPL4K.
call 'SIMOPL4K' using PASS-AREA-PL4K
The following is a list of the parameters required when using the PASS-AREA-PL4K to call the SIMOPL4K routine.
| Parameter | Description | ||||||||
| PA-PL4K-REQUEST | This parameter must be provided by the calling program.
|
||||||||
| PA-PL4K-STATUS | A "0000" value indicates a successful completion of the request. A non-zero string indicates the request could not be completed successfully. | ||||||||
| PA-PL4K-STORAGE | If the content of PA-PL4K-REQUEST equals "PUT" then this parameter will contain the logical record for a PUT (or write) request. |
Note: A listing of the COBOL copy file is provided in a following section of this document.
The SIMOPL4K program that writes a Line Sequential file uses the file name of "LS04KPUT" when accessing the file. To have the program access the correct file the location and name of the physical file must be mapped to the name used by the program. This is accomplished by using an environment variable. The following shows how this is accomplished.
set LS04KPUT=d:\mydirectory\filename.ext
The following (SIMOPL4K.cbl) is a listing of the COBOL Source Code.
IDENTIFICATION DIVISION.
PROGRAM-ID. SIMOPL4K.
*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 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. *
* *
* 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. *
* *
* 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 Member: SIMOPL4K.CBL
*****************************************************************
*
* SIMOPL4K - Write a record to an ASCII/Text File.
*
* CALLING PROTOCOL
* ----------------
* First, the pass area (or data structure) must be defined in
* the WORKING-STORAGE section of the program that will call
* SIMOPL4K. A COBOL copy file is provided for this purpose and
* the same copy file is used in the LINKAGE section of SIMOPL4K.
*
* COPY PASSPL4K.
*
* Next, the data items in the pass area need to be initialized
* prior to calling SIMOPL4K.
*
* move 'OPEN' to PA-PL4K-REQUEST
* move '0000' to PA-PL4K-RESPOND
* move SPACES to PA-PL4K-STORAGE
*
* Next, the following shows the line of code that makes the call
* to SIMOPL4K.
*
* call 'SIMOPL4K' using PASS-AREA-PL4K
*
* The following is a list of the parameters required when using
* the PASS-AREA-PL4K to call the SIMOPL4K routine.
*
* Parameter Description
* --------------- ---------------------------------------------
* PA-PL4K-REQUEST This parameter must be provided by the
* calling program.
* Keyword Description
* ------- -----------------------------------
* PUT Put (or Write) a logical record to
* a Line Sequential (or ASCII/Text)
* file with a maximum record length
* of 4,096 bytes.
* OPEN Open for OUTPUT or write access.
* CLOS Close the file.
* PA-PL4K-STATUS A "0000" value indicates a successful
* completion of the request. A non-zero string
* indicates the request could not be completed
* successfully.
* PA-PL4K-STORAGE If the content of PA-PL4K-REQUEST equals
* "PUT" then this parameter will contain the
* logical record for a PUT (or write) request.
*
*****************************************************************
*
* MAINTENANCE
* -----------
* 1997/12/18 Simmons, Created program.
* 1997/12/18 Simmons, No changes to date.
*
*****************************************************************
*
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT LS04KPUT-FILE ASSIGN TO LS04KPUT
ORGANIZATION IS LINE SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS LS04KPUT-STATUS.
*****************************************************************
DATA DIVISION.
FILE SECTION.
FD LS04KPUT-FILE
DATA RECORD IS LS04KPUT-REC
.
01 LS04KPUT-REC.
05 LS04KPUT-DATA-01 PIC X(4096).
*****************************************************************
WORKING-STORAGE SECTION.
01 LS04KPUT-STATUS.
05 LS04KPUT-STATUS-L pic X.
05 LS04KPUT-STATUS-R pic X.
01 LS04KPUT-EOF pic X value 'N'.
01 LS04KPUT-OPEN-FLAG pic X value 'C'.
01 LS04KPUT-LRECL pic 9(5) value 4096.
*****************************************************************
* 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 '* SIMOPL4K '.
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 'SIMOPL4K'.
01 INFO-STATEMENT.
05 INFO-SHORT.
10 INFO-ID pic X(8) value 'Starting'.
10 filler pic X(2) value ', '.
10 filler pic X(34)
value 'Convert LCSV to HTML of 4096 LRECL'.
05 filler pic X(24)
value ' http://www.SimoTime.com'.
01 APPL-RESULT pic S9(9) comp.
88 APPL-AOK value 0.
88 APPL-EOF value 16.
01 BEHAVIOR-FLAGS.
05 BF-01 pic X value 'N'.
05 BF-02 pic X value 'N'.
05 BF-03 pic X value 'N'.
05 BF-04 pic X value 'N'.
05 BF-05 pic X value 'N'.
05 BF-06 pic X value 'N'.
05 BF-07 pic X value 'N'.
05 BF-08 pic X value 'N'.
05 BF-SEPARATE pic X value '/'.
05 BF-T1 pic X value 'N'.
05 BF-T2 pic X value 'N'.
05 BF-T3 pic X value 'N'.
05 BF-T4 pic X value 'N'.
05 BF-T5 pic X value 'N'.
05 BF-T6 pic X value 'N'.
05 BF-T7 pic X value 'N'.
05 BF-T8 pic X value 'N'.
01 LS04KPUT-TOTAL.
05 LS04KPUT-RDR pic 9(9) value 0.
05 filler pic X(3) value ' - '.
05 filler pic X(23) value 'Line count for LS04KPUT'.
01 WORK-64 pic x(64) value SPACES.
01 KEYWORD-12 pic x(12) value SPACES.
01 H-NAME pic X(64) value SPACES.
01 H-NUMB pic 9(5) value 0.
01 IX-1 pic 9(5) value 0.
01 IX-2 pic 9(5) value 0.
01 RP-1 pic 9(5) value 0.
01 HTMGEND2-LSC pic 9(5) value 0.
01 DOUBLE-QUOTE pic X value '"'.
01 SINGLE-QUOTE pic X value "'".
01 H-ID-START pic X(5) value '<H1 >'.
01 H-ID-CLOSE pic X(5) value '</H1>'.
01 H-TABLE-DATA.
05 H-TABLE occurs 250 times.
10 H-TABLE-ID pic X(03) value SPACES.
10 H-TABLE-TX pic X(61) value SPACES.
01 HX-COUNT pic 9(5) value 0.
01 HX-LIMIT pic 9(5) value 250.
01 HX-1 pic 9(5) value 0.
01 TOC-FLAG pic X value 'N'.
01 TOC-LEVEL-ACTIVE pic 9(3) value 0.
01 NESW-FLAGS pic X(4) value 'NNNN'.
01 TP-1 pic 9(5) value 0.
01 U-CASE pic X(26) value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
01 L-CASE pic X(26) value 'abcdefghijklmnopqrstuvwxyz'.
01 WORK-256 pic X(256) value SPACES.
*****************************************************************
LINKAGE SECTION.
COPY PASSPL4K.
*01 PASS-AREA-PL4K.
* 05 PA-PL4K-REQUEST pic X(4).
* 05 PA-PL4K-RESPOND pic X(4).
* 05 PA-PL4K-STORAGE pic X(4096).
*****************************************************************
PROCEDURE DIVISION using PASS-AREA-PL4K.
evaluate PA-PL4K-REQUEST
when 'PUT ' perform ACTION-PUT
when 'OPEN' perform LS04KPUT-OPEN-OUTPUT
move LS04KPUT-STATUS to IO-STATUS
perform Z-CALCULATE-IO-STATUS
move IO-STATUS-04 to PA-PL4K-RESPOND
when 'CLOS' perform LS04KPUT-CLOSE
move LS04KPUT-STATUS to IO-STATUS
perform Z-CALCULATE-IO-STATUS
move IO-STATUS-04 to PA-PL4K-RESPOND
when 'FLAG' move PA-PL4K-STORAGE(1:17) to BEHAVIOR-FLAGS
when other perform ACTION-ERROR
end-evaluate
GOBACK.
*****************************************************************
ACTION-ERROR.
move '0016' to PA-PL4K-RESPOND
exit.
*****************************************************************
ACTION-PUT.
if LS04KPUT-OPEN-FLAG not = 'O'
perform LS04KPUT-OPEN-OUTPUT
end-if
move PA-PL4K-STORAGE to LS04KPUT-REC
perform LS04KPUT-WRITE
move LS04KPUT-STATUS to IO-STATUS
perform Z-CALCULATE-IO-STATUS
move IO-STATUS-04 to PA-PL4K-RESPOND
exit.
*****************************************************************
* I/O Routines for the INPUT File... *
*****************************************************************
LS04KPUT-CLOSE.
add 8 to ZERO giving APPL-RESULT.
close LS04KPUT-FILE
if LS04KPUT-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'C' to LS04KPUT-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
move 'E' to LS04KPUT-OPEN-FLAG
end-if
if APPL-AOK
CONTINUE
else
move 'CLOSE Failure with LS04KPUT' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move LS04KPUT-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
* perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
LS04KPUT-WRITE.
write LS04KPUT-REC
if LS04KPUT-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if LS04KPUT-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 LS04KPUT-EOF
else
move 'WRITE Failure with LS04KPUT' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move LS04KPUT-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
* perform Z-ABEND-PROGRAM
end-if
end-if
exit.
*---------------------------------------------------------------*
LS04KPUT-OPEN-OUTPUT.
add 8 to ZERO giving APPL-RESULT.
open output LS04KPUT-FILE
if LS04KPUT-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'O' to LS04KPUT-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
if BF-T1 = 'Y'
move 'OPEN Failure with LS04KPUT' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move LS04KPUT-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
* perform Z-ABEND-PROGRAM
end-if
end-if
exit.
*****************************************************************
* The following Z-ROUTINES provide administrative functions *
* for this program. *
*****************************************************************
* ABEND the program, post a message to the console and issue *
* a STOP RUN. *
*****************************************************************
Z-ABEND-PROGRAM.
if MESSAGE-TEXT not = SPACES
perform Z-DISPLAY-MESSAGE-TEXT
end-if
move 'PROGRAM-IS-ABENDING...' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
add 12 to ZERO giving RETURN-CODE
STOP RUN.
* exit.
*****************************************************************
Z-CALCULATE-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
else
move '0000' to IO-STATUS-04
move IO-STATUS to IO-STATUS-04(3:2)
end-if
exit.
*****************************************************************
* Display SYSOUT 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.
perform Z-CALCULATE-IO-STATUS
move 'File Status Code is ' to MESSAGE-TEXT
move IO-STATUS-04 to MESSAGE-TEXT(21:4)
perform Z-DISPLAY-MESSAGE-TEXT
exit.
*****************************************************************
* This program was generated by SimoZAPS *
* A product of SimoTime Technologies *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* Generation Date: 2010-09-24 Generation Time: 15:13:20:88 *
*****************************************************************
The following (PASSPL4K.cpy) is a listing of the COBOL Copy file that defines the structure for the data items in the pass area.
*****************************************************************
* PASSPL4K.cpy a COBOL Copy File *
* Data Structure for SIMOPL4K Pass Area. *
* Copyright (C) 1987-2019 SimoTime Technologies *
* All Rights Reserved *
* Provided by SimoTime Technologies *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
*
* PASS-AREA-PL4K Pass Area used when calling SIMOPL4K
* PA-PL4K-REQUEST User Request
* OPEN Open the file with read-only access
* PUT Write a record to the file
* CLOS Close the file
* FLAG Set Program-Behavior Flags
* PA-PL4K-RESPOND Program Response to calling program
* PA-PL4K-STORAGE Contains Data from the PUT request
*
01 PASS-AREA-PL4K.
05 PA-PL4K-REQUEST pic X(4).
05 PA-PL4K-RESPOND pic X(4).
05 PA-PL4K-STORAGE pic X(4096).
*** PASSPL4K - End-of-Copy File - - - - - - - - - - - PASSPL4K *
*****************************************************************
*
The primary purpose of this document is to provide a COBOL Source member for viewing. This document may be used as a tutorial for new programmers or as a quick reference for experienced programmers.
In the world of programming there are many ways to solve a problem. This documentation and software were developed and tested on systems that are configured for a SIMOTIME environment based on the hardware, operating systems, user requirements and security requirements. Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration.
SIMOTIME Services has experience in moving or sharing data or application processing across a variety of systems. For additional information about SIMOTIME Services or Technologies please contact us using the information in the Contact, Comment or Feedback section of this document.
Software Agreement and Disclaimer
Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Technologies. Once the fee is received by SimoTime the latest version of the software, documentation or training material will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Technologies.
SimoTime Technologies makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose. It is provided "AS IS" without any expressed or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Technologies shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software, documentation or training material.
This section includes links to documents with additional information that are beyond the scope and purpose of this document. The first group of documents may be available from a local system or via an Internet connection, the second group of documents will require an internet connection.
Note: A SimoTime License is required for the items to be made available on a local system or server.
The following links may be to the current server or to the Internet.
Note: The latest versions of the SimoTime Documents and Program Suites are available on the Internet and may be accessed using the
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
icon.
Explore The ASCII and EBCDIC Translation Tables. These tables are provided for individuals that need to better understand the bit structures and differences of the encoding formats.
Explore The File Status Return Codes that are used to interpret the results of accessing VSAM data sets and/or QSAM files.
The following links will require an Internet connect.
A good place to start is The SimoTime Home Page for access to white papers, program examples and product information. This link requires an Internet Connection
Explore The Micro Focus Web Site for more information about products (including Micro Focus COBOL) and services available from Micro Focus. This link requires an Internet Connection.
Explore the GnuCOBOL Technologies available from SourceForge. SourceForge is an Open Source community resource dedicated to helping open source projects be as successful as possible. GnuCOBOL (formerly OpenCOBOL) is a COBOL compiler with run time support. The compiler (cobc) translates COBOL source to executable using intermediate C, designated C compiler and linker. This link will require an Internet Connection.
Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.
This document was created and is maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please use the following contact information.
| 1. | Send an e-mail to our helpdesk. |
| 1.1. | helpdesk@simotime.com. |
| 2. | Our telephone numbers are as follows. |
| 2.1. | 1 415 763-9430 office-helpdesk |
| 2.2. | 1 415 827-7045 mobile |
We appreciate hearing from you.
SimoTime Technologies was founded in 1987 and is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. Our customers include small businesses using Internet technologies to corporations using very large mainframe systems.
Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms.
Preparing the application programs will require the transfer of source members that will be compiled and deployed on the target platform. The data will need to be transferred between the systems and may need to be converted and validated at various stages within the process. SimoTime has the technology, services and experience to assist in the application and data management tasks involved with doing business in a multi-system environment.
Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com
| Return-to-Top |
| Write Access to a Line Sequential File |
| Copyright © 1987-2024 SimoTime Technologies and Services All Rights Reserved |
| When technology complements business |
| http://www.simotime.com |