![]() |
Assembler I/O Routine COBOL calls Assembler, VSAM Access |
| When technology complements business | Copyright © 1987-2012 SimoTime Enterprises All Rights Reserved |
| The SimoTime Home Page |
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.
The following is the logic flow of a batch job that executes a COBOL program that calls an Asssembler I/O routine.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Overview, COBOL Program calling an Assembler I/O Routine to Read a Sequential File |
Note: The light-green boxes are unique to the Mainframe and Micro Focus Enterprise Server/Studio (or Micro Focus Mainframe Express). The light-red boxes are unique to the PC with Windows and Micro Focus. The light-yellow boxes are decision points or program transitions in the processing logic. The light-blue boxes identify data structures such as Files, VSAM Data Sets or Relational Tables. The light-gray boxes identify a system function or information item.
The 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.
The 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-2012 SimoTime Enterprises *
* All Rights Reserved *
* Provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
*
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 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) //* ******************************************************************* //* This program is provided by: SimoTime Enterprises * //* (C) Copyright 1987-2012 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 Enterprises //* 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 will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* ************ //* * 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 //*
This 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 ENTERPRISES.
*****************************************************************
* Copyright (C) 1987-2012 SimoTime Enterprises. *
* *
* 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 *
* Enterprises. *
* *
* 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. *
* *
* SimoTime Enterprises 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 *
* 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 *
* *
* SimoTime Enterprises *
* 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 Enterprises, *
* 15 Carnoustie Drive, Novato, CA 94949-5849. *
* *
*****************************************************************
* This program is provided by SimoTime Enterprises *
* 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-2012 '.
05 C3 pic X(28) value '--- SimoTime Enterprises ---'.
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 softwar'.
05 C3 pic X(32) value 'e provided from SimoTime Enterpr'.
05 C4 pic X(04) value 'ises'.
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 Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
This 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 Enterprises *
* (C) Copyright 1987-2012 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 an 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
The purpose of this document is 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 document and the links to other documents are intended to provide a choice of alternatives.
Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Enterprises. 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 Enterprises.
SimoTime Enterprises 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 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, documentation or training material.
This section includes links to documents with additional information that is beyond the scope and purpose of this document. The first sub-section requires an internet connection, the second sub-section references locally available documents.
Note: A SimoTime License is required for the items to be made available on a local server.
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 suite of programs and documentation is available for download. Link to an Evaluation zPAK Option that includes the program members, documentation and control files.
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 to interpret the results of accessing VSAM data sets and QSAM files.
Explore The Micro Focus Web Site for more information about products and services available from Micro Focus.
The following links may be accessible without an internet connection.
Explore The File Status Return Codes to interpret the results of accessing VSAM data sets and QSAM files.
Check out The SimoTime Glossary for a list of terms and definitions used in the documents provided by SimoTime.
This document was created and is maintained by SimoTime Enterprises.
If you have any questions, suggestions, comments or feedback please call or send an e-mail to: helpdesk@simotime.com
We appreciate hearing from you.
Founded in 1987, SimoTime Enterprises is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems.
Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com
| Return-to-Top |
| VSAM Access from Assembler called by COBOL |
| Copyright © 1987-2012 SimoTime Enterprises All Rights Reserved |
| When technology complements business |
| http://www.simotime.com |