Assembler I/O Routine COBOL calls Assembler, VSAM Access |
This suite of programs provides an example of how a mainline COBOL program calls a mainframe assembler (HLASM) I/O routine to access a VSAM data set. The VSAM data set is a Keyed-Sequential-Data-Set (KSDS). The COBOL program is written using COBOL/2 dialect but also works with COBOL for MVS and COBOL/370. The assembler IO routine is written in IBM Mainframe Assembler, it will compile using Assembler/H or HLASM. A JCL member is provided to run the job as an MVS batch job on an IBM mainframe or as a project with Micro Focus Mainframe Express (MFE) running on a PC with Windows.
This program may serve as a tutorial for programmers that are new to COBOL, 370 Assembler or QSAM and as a reference for experienced programmers. Additional information is provided in the Downloads and Links to Similar Pages section of this document.
We have made a significant effort to ensure the documents and software technologies are correct and accurate. We reserve the right to make changes without notice at any time. The function delivered in this version is based upon the enhancement requests from a specific group of users. The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources.
Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved
The following is the logic flow of a batch job that executes a COBOL program that calls an Assembler I/O routine.
Color Associations: The The Call InterfaceThe following summarizes the items needed for a Caller (CBLASMC1.cbl) to call a Called program (CBLASMA1). The Caller program" contains the following statement to make the call to the Called. CALL 'CBLASMA1' USING PASS-AREA The source code listings for both the Caller program and the Called program are included within this document. Call Interface, COBOL Copy FileThe Caller program needs the following data structure (PASS-AREA) to be defined in the WORKING-STORAGE section. ***************************************************************** * CBLASMB1.CPY - a COBOL Copy File * * 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 * ***************************************************************** * 01 PASS-AREA. 05 PASS-REQUEST pic X(8). 05 PASS-RESULT pic S9(9) comp. 88 NORMAL-RESULT value 0. 88 COBOL-RESULT-SAME value 8. 88 EOF-RESULT value 16. 05 PASS-RECORD. 10 PASS-KEY pic X(6). 10 PASS-INFO pic X(74). * *** CBLASMB1 - End-of-Copy File - - - - - - - - - - - CBLASMB1 * ***************************************************************** * The JCL MemberThe following is the JCL member (CBLASMJ1.jcl) required to run as an MVS job on the mainframe. This job will also run with Micro Focus Mainframe Express. The coding technique is used with the expectation the JCL would be used as a stand alone procedure. //CBLASMJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1, // COND=(0,LT) //* ******************************************************************* //* CBLASMJ1.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - COBOL calling 370 Assembler for VSAM I/O. //* Author - SimoTime Technologies //* Date - January 01, 1997 //* //* This set of programs illustrate the use of COBOL calling a 370 //* assembler program to do VSAM sequential I/O. The purpose is to //* show the processing of a VSAM Keyed Sequential Data Set (KSDS). //* //* This set of programs may be compiled and executed on a Mainframe //* System with ZOS or a Linux, UNIX or Windows System with Micro Focus //* Enterprise Developer. //* //* ************ //* * CBLASMJ1 * //* ********jcl* //* * //* ************ ************ //* * CBLASMC1 *****call*** CBLASMA1 * //* ********cbl* * ********asm* //* * * * //* * * * //* * * ************ //* * * * VKSD0080 * //* * * ********get* //* * * //* * * ************ //* * ********* DISPLAY * //* * ************ //* * //* ************ //* * EOJ * //* ************ //* //* ******************************************************************* //* Step 1 of 1, This is a single step job. //* //CBLASMS1 EXEC PGM=CBLASMC1 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //VKSD0080 DD DSN=SIMOTIME.DATA.VKSD0080,DISP=SHR //* The COBOL ProgramThis program (CBLASMC1.cbl) was written to be used as a teaching and learning aid. The displays are not required and the parameters use full words. The displays would probably be removed and the request codes would probably be a single character in a production environment. IDENTIFICATION DIVISION. PROGRAM-ID. CBLASMC1. 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: CBLASMC1.CBL * Calls to: CBLASMA1 ***************************************************************** * * CBLASMC1 - Call CBLASMA1 to access a VSAM Keyed Sequential * Data Set (KSDS). * * EXECUTION or CALLING PROTOCOL * ----------------------------- * Use standard JCL to EXECUTE or ANIMATE. * * DESCRIPTION * ----------- * This program will call a 370 Assembler routine to access a * VSAM Keyed Sequential Data Set (KSDS). * * ************ * * CBLASMJ1 * * ********jcl* * * * * * ************ ************ * * CBLASMC1 *-----* CONSOLE * * ********cbl* ******dsply* * * * * * ************ ************ * * VKSD0080 *-----* CBLASMA1 * * *******vsam* ********mlc* * * ***************************************************************** * * MAINTENANCE * ----------- * 1997/02/27 Simmons, Created program. * 1997/02/27 Simmons, No changes to date.. * ***************************************************************** * ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. ***************************************************************** * Data-structure for Title and Copyright... * ------------------------------------------------------------ 01 SIM-TITLE. 05 T1 pic X(11) value '* CBLASMC1 '. 05 T2 pic X(34) value 'Sample, COBOL calls Assembler I/O '. 05 T3 pic X(10) value ' v03.01.24'. 05 T4 pic X(24) value ' http://www.simotime.com'. 01 SIM-COPYRIGHT. 05 C1 pic X(11) value '* CBLASMC1 '. 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'. 01 SIM-THANKS-01. 05 C1 pic X(11) value '* CBLASMC1 '. 05 C2 pic X(32) value 'Thank you for using this program'. 05 C3 pic X(32) value ' provided from SimoTime Technolo'. 05 C4 pic X(04) value 'gies'. 01 SIM-THANKS-02. 05 C1 pic X(11) value '* CBLASMC1 '. 05 C2 pic X(32) value 'Please send all inquires or sugg'. 05 C3 pic X(32) value 'estions to the helpdesk@simotime'. 05 C4 pic X(04) value '.com'. 01 REQUEST-OPEN pic X(8) value 'OPEN '. 01 REQUEST-GET pic X(8) value 'GET '. 01 REQUEST-CLOSE pic X(8) value 'CLOSE '. 01 REQUEST-KEY pic X(6). 01 END-OF-FILE pic X(3) value 'NO '. 01 OPERATOR-MESSAGE pic X(48). COPY CBLASMB1. ***************************************************************** PROCEDURE DIVISION. perform Z-POST-COPYRIGHT display '* CBLASMC1 OPEN Request...' upon console. perform OPEN-THE-FILE. display '* CBLASMC1 OPEN Complete...' upon console. perform until END-OF-FILE = 'YES' if END-OF-FILE = 'NO ' move REQUEST-GET to PASS-REQUEST move REQUEST-KEY to PASS-KEY perform GET-NEXT-RECORD if END-OF-FILE = 'NO ' display PASS-INFO upon console end-if end-if end-perform. perform CLOSE-THE-FILE. display '* CBLASMC1 has COMPLETED...' upon console perform Z-THANK-YOU. GOBACK. ***************************************************************** GET-NEXT-RECORD. call 'CBLASMA1' using PASS-AREA. if NORMAL-RESULT CONTINUE else if EOF-RESULT move 'YES' to END-OF-FILE else move '* CBLASMC1, QKSD001F, FAILURE, GET...' to OPERATOR-MESSAGE perform Z-ABEND-MESSAGE STOP RUN end-if end-if exit. OPEN-THE-FILE. add 8 to ZERO giving PASS-RESULT. move REQUEST-OPEN to PASS-REQUEST. call 'CBLASMA1' using PASS-AREA. if NORMAL-RESULT CONTINUE else move '* CBLASMC1, QKSD001F, FAILURE, OPEN...' to OPERATOR-MESSAGE perform Z-ABEND-MESSAGE add 12 to ZERO giving RETURN-CODE STOP RUN end-if exit. CLOSE-THE-FILE. add 8 to ZERO giving PASS-RESULT. move REQUEST-CLOSE to PASS-REQUEST. call 'CBLASMA1' using PASS-AREA. if NORMAL-RESULT CONTINUE else move '* CBLASMA1, QKSD001F, FAILURE, CLOSE...' to OPERATOR-MESSAGE perform Z-ABEND-MESSAGE add 12 to ZERO giving RETURN-CODE STOP RUN end-if exit. ***************************************************************** * The following Z-Routines perform administrative functions * * for this program. * ***************************************************************** Z-ABEND-MESSAGE. if OPERATOR-MESSAGE not = SPACES perform Z-DISPLAY-CONSOLE-MESSAGE else move '* CBLASMC1 IS ABENDING...' to OPERATOR-MESSAGE perform Z-DISPLAY-CONSOLE-MESSAGE end-if exit. Z-DISPLAY-CONSOLE-MESSAGE. display OPERATOR-MESSAGE upon console move SPACES to OPERATOR-MESSAGE exit. Z-POST-COPYRIGHT. display SIM-TITLE upon console display SIM-COPYRIGHT upon console exit. ***************************************************************** Z-THANK-YOU. display SIM-THANKS-01 upon console display SIM-THANKS-02 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 * ***************************************************************** The Assembler I/O RoutineThis program (CBLASMA1.mlc) does not provide much visual information when it is executed on the mainframe. The real value to this program is when it is animated using the 370 Assembler Option of Mainframe Express provided by Micro Focus. It is possible to watch the actual execution of each individual instruction and to immediately see the results. CBLASMA1 CSECT *********************************************************************** * CBLASMA1.MLC - This is an HLASM Program * * Provided by SimoTime Technologies * * (C) Copyright 1987-2019 All Rights Reserved * * Web Site URL: http://www.simotime.com * * e-mail: helpdesk@simotime.com * *********************************************************************** * * * Created: 1988/06/01, Simmons * * Changed: 1993/03/01, Simmons, Migrate to Micro Focus * * * *********************************************************************** * * * This program will run on an IBM Mainframe using MVS or a PC using * * Micro Focus Mainframe Express, version 2.5 or later (MFE) with * * the Assembler Option. * * * * This program provides an example of an assembler I/O sub-routine * * that provides access to a VSAM Keyed-Sequential-Data-Set (KSDS). * * * * Using the Micro Focus Animation You can immediately see the results * * of each instruction execution. This is a very effective way to * * become familiar with how these techniques work. * * * *********************************************************************** * CBLASMA1, This program will read a KSDS, VSAM file sequentially. * * * * * * From To Length Description * * 1 6 6 Primary Key * * 7 7 1 Space * * 8 17 10 Alpha-Numeric "RECORD nn" * * 18 18 1 Space * * 19 22 4 Alpha-Numeric "KSDS" * * 23 23 1 Space * * 24 30 7 Alpha-Numeric "xxxxxxx" where x = A-Z * * 31 50 20 Secondary-Key "CONSONANT " * * "VOWEL " * * "VOWEL/CONSONANT " * * 51 80 30 Alpha-Numeric "xxx..." where x = A-Z * * * *********************************************************************** * R0 EQU 0 R1 EQU 1 R2 EQU 2 R3 EQU 3 R4 EQU 4 R5 EQU 5 R6 EQU 6 R7 EQU 7 R8 EQU 8 R9 EQU 9 R10 EQU 10 R11 EQU 11 R12 EQU 12 R13 EQU 13 R14 EQU 14 R15 EQU 15 * SAVE (14,12) BALR 12,0 USING *,12 * ST R1,SAVER1 * SAVE REGISTER 1 L R8,0(,R1) * GET ADDRESS OF PASS AREA * CLC 0(8,R8),GET * IS THIS AN GET REQUEST... BE GETRTN * CLC 0(8,R8),OPEN * IS THIS AN OPEN REQUEST... BE OPENRTN * CLC 0(8,R8),CLOSE * IS THIS AN CLOSE REQUEST... BE CLOSERTN * LA R15,15 B RETURN * OPENRTN EQU * OPEN (VSAMFILE,(INPUT)) LTR R15,R15 * WAS OPEN SUCCESSFUL ??? BNZ BADOPEN * IF NOT, THEN QUIT TESTCB ACB=VSAMFILE,OFLAGS=OPEN BNZ BADOPEN ST R15,8(,R8) B RETURN * GETRTN EQU * MVC USERKEY(6),12(R8) * MOVE REQ KEY RPL KEY FIELD MVI RECORD,C' ' * PREPARE TO INIT RECORD AREA MVC RECORD+1(79),RECORD INITIALIZE RECORD AREA MVC 12(80,R8),RECORD * CLEAR PASS-AREA BUFFER GET RPL=SEQRET ST R15,SAVE15 * SAVE RETURN CODE LTR R15,R15 * IS RETURN CODE = 0 ??? BNZ BADGET IF NOT, THEN POST A MESSAGE MVC 12(80,R8),RECORD * MOVE DATA TO USER PASS AREA ST R15,8(,R8) SET USER RETRUN CODE TO ZERO B RETURN * CLOSERTN EQU * CLOSE VSAMFILE LTR 15,15 BNZ BADCLOSE ST R15,8(,R8) B RETURN * RETURN EQU * SR 15,15 SET USER RETURN CODE TO ZERO RETURN (14,12),RC=(15) * EODRTN EQU * WTO '* CBLASMA1 THE END-OF-FILE HAS BEEN PROCESSED' LA R15,16 ST R15,8(,R8) * SET USER RETURN CODE TO ZERO RETURN (14,12),RC=(15) * BADTEST EQU * ST R15,8(,R8) * SET USER RETURN CODE TO ZERO WTO '* CBLASMA1 THE TESTCB FOR VSAM FEEDBACK CODE FAILED' L R15,8(,R8) RETURN (14,12),RC=(15) * ERROR1 EQU * ST R15,8(,R8) * SET USER RETURN CODE TO ZERO WTO '* CBLASMA1 SYNAD ERROR PROCESSING' L R15,8(,R8) RETURN (14,12),RC=(15) * BADOPEN EQU * ST R15,8(,R8) * SET USER RETURN CODE TO ZERO WTO '* CBLASMA1 THE FILE OPEN FAILED...' L R15,8(,R8) RETURN (14,12),RC=(15) * BADGET EQU * ST R15,8(,R8) * SET USER RETURN CODE TO ZERO WTO '* CBLASMA1 THE FILE GET FAILED...' L R15,8(,R8) RETURN (14,12),RC=(15) * BADCLOSE EQU * ST R15,8(,R8) * SET USER RETURN CODE TO ZERO WTO '* CBLASMA1 THE FILE CLOSE FAILED...' L R15,8(,R8) RETURN (14,12),RC=(15) * VSAMFILE ACB AM=VSAM,EXLST=MSTEXL,DDNAME=VKSD0080,MACRF=(SEQ,IN) MSTEXL EXLST EODAD=EODRTN,SYNAD=ERROR1 SEQRET RPL AM=VSAM,ACB=VSAMFILE,AREA=RECORD,AREALEN=80, X OPTCD=(KEY,SEQ),KEYLEN=6,ARG=USERKEY * SEQRETA DC A(SEQRET) USERKEY DC F'0' SAVE15 DS F'0' RECORD DS CL256 * SAVER1 DC F'0' GET DC CL8'GET ' OPEN DC CL8'OPEN ' CLOSE DC CL8'CLOSE ' END SummaryThis suite of programs provides an example of how a mainline COBOL program calls a mainframe assembler (HLASM) I/O routine to access a VSAM data set. This document may be used to assist as a tutorial for new programmers or as a quick reference for experienced programmers. In the world of programming there are many ways to solve a problem. This documentation and software were developed and tested on systems that are configured for a SIMOTIME environment based on the hardware, operating systems, user requirements and security requirements. Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration. SIMOTIME Services has experience in moving or sharing data or application processing across a variety of systems. For additional information about SIMOTIME Services or Technologies please contact us using the information in the Contact or Feedback section of this document.
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. Downloads and LinksThis 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. Current Server or Internet AccessThe 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 Assembler Connection for more examples of mainframe Assembler programming techniques and sample code. Explore the JCL Connection for more examples of JCL functionality with programming techniques and sample code. Explore the COBOL Connection for more examples of COBOL programming techniques and sample code. 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. 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. Internet Access RequiredThe following links will require an internet connect. This suite of programs and documentation is available to download for review and evaluation purposes. Other uses will require a SimoTime Software License. Link to an Evaluation zPAK Option that includes the program members, documentation and control files. A good place to start is The SimoTime Home Page for access to white papers, program examples and product information. This link requires an Internet Connection Explore The Micro Focus Web Site for more information about products (including Micro Focus COBOL) and services available from Micro Focus. This link requires an Internet Connection. Glossary of TermsExplore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers. Contact or FeedbackThis document was created and is maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please use the following contact information.
We appreciate hearing from you. Company OverviewSimoTime 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
|