For Assembler programmers, simply LINK (or optionally, LOAD and BALR) to GVFILDYN. Upon return from GVFILDYN, the entry points for GVOPEN, GVREAD, and GVCLOSE are established. The Assembler programmer can then LINK (or LOAD and BALR) to GVOPEN, GVREAD, or GVCLOSE as needed.
Note: GVFILDYN and GVFILE must be in an active link list library.
The following examples use GVFILDYN to establish the entry points for GVOPEN, GVREAD, and GVCLOSE. GVFILDYN is called first. GVFILDYN loads GVFILE and dynamically defines the entry points for GVOPEN, GVREAD, and GVCLOSE to the operating system.
LINK EP=GVFILDYN Set up GVOPEN, GVREAD, and GVCLOSE
LOAD EP=GVOPEN Get OPEN entry point
ST R0,@GVOPEN Save GVOPEN addr for calls
LOAD EP=GVREAD Get GVREAD entry point
ST R0,@GVREAD Save GVREAD addr for calls
LOAD EP=GVCLOSE Get GVCLOSE entry point
ST R0,@GVCLOS Save GVCLOSE add for calls
*
NEXT XC NAME,NAME Give me the next file on tape
L R15,@GVOPEN Get addr of GVOPEN routine
CALL (15),(NAME) Call open/Locate entry point
C R15,=F'16' Test return code
BE ERROR Unable to open FVRFILE
C R15,=F'18' End of all files on tapes?
BE EOJ If so, then we're through
CLC NAME,SRCHNAM1 Is this one we want?
BE COPYIT If so, go copy it
CLC NAME,SRCHNAM2 Is this one we want?
BE COPYIT If so, go copy it
B NEXT Else, go find next file
COPYIT BAL R14,COPY Copy this file to output
B NEXT Continue searching
EOJ L R15,@GVCLOS Pick up addr of GVCLOSE routine
CALL (15) Call GVCLOSE
B RETURN We're through
NAME DS CL44 Hex zeros before call,
* name on return
SRCHNAM1 DC CL44'desired.cluster.name1'
SRCHNAM2 DC CL44'desired.cluster.name2'
@GCOPEN DC A(0) GVOPEN entry point
@GCREAD DC A(0) GVREAD entry point
@GCCLOS DC A(0) GVCLOSE entry point
The following locates a specific cluster:
LINK EP=GVFILDYN Set up GVOPEN, GVREAD, and GVCLOSE
LOAD EP=GVOPEN Get OPEN entry point
ST R0,@GVOPEN Save GVOPEN addr for calls
LOAD EP=GVREAD Get GVREAD entry point
ST R0,@GVREAD Save GVREAD addr for calls
LOAD EP=GVCLOSE Get GVCLOSE entry point
ST R0,@GVCLOS Save GVCLOSE add for calls
L R15,@GVOPEN Get addr of GVOPEN routine
CALL (15),(NAME) Call open/Locate entry point
LTR R15,R15 Test return code
BNZ NOTFND Cluster not found or open error
BAL R14,COPY Copy the cluster dataI
L R15,@GVCLOS Pick up addr of GVCLOSE routine
CALL (15) Call GVCLOSE
B RETURN We're through
NAME DC CL44'desired.cluster.name' Search argument for GVOPEN
@GCOPEN DC A(0) GVOPEN entry point
@GCREAD DC A(0) GVREAD entry point
@GCCLOS DC A(0) GVCLOSE entry point
The following finds a cluster whose name you specify in a text file. Add to JCL:
//SELECT DD *
desired.cluster.name
/*
LINK EP=GVFILDYN Set up GVOPEN, GVREAD, and GVCLOSE
LOAD EP=GVOPEN Get OPEN entry point
ST R0,@GVOPEN Save GVOPEN addr for calls
LOAD EP=GVREAD Get GVREAD entry point
ST R0,@GVREAD Save GVREAD addr for calls
LOAD EP=GVCLOSE Get GVCLOSE entry point
ST R0,@GVCLOS Save GVCLOSE add for calls
CALL GVOPEN,(NAME) Call open/Locate entry point
LTR R15,R15 Test return code
BNZ ERROR Error encountered
BAL R14,COPY Copy the file data
L R15,@GVCLOS Pick up addr of GVCLOSE routine
CALL (15) Call GVCLOSE
B RETURN Go shut down
NAME DC CL44'DDNAME=SELECT' Tell GVOPEN cluster name in //SELECT
@GCOPEN DC A(0) GVOPEN entry point
@GCREAD DC A(0) GVREAD entry point
@GCCLOS DC A(0) GVCLOSE entry point
This example goes with the examples for GVOPEN in the previous section. This code segment reads all of the data records for the currently selected file. The examples under GVOPEN call this code through a "BAL R14,COPY" instruction.
COPY ST R14,SAVLNK Save return point in mainline
COPY1 L R15,@GVREAD Get GVREAD routine addr
CALL (15),(LENGTH,RECORD) Call GVREAD for next record
LTR R15,R15 Did we get a record?
BZ COPY2 If so, then continue
C R15,=F'8' End of data?
BE COPY9 If so, copy is complete
B ERROR Else, an error was detected
COPY2 L R1,LENGTH Get record length
LA R1,4(R1) For VB file, add len of RDW
SLL R1,16 Make RDW 0000LLLL --> LLLL0000
ST R1,RDW Convert len to RDW
PUT OUTPUT,RDW Write out data record
B COPY1 Go get next record
COPY9 L R14,SAVLNK Get return address
BR R14 Return to mainline
SAVLNK DS A Holds return point in mainline
LENGTH DS F Return length of record here
RDW DS F RDW for output record
RECORD DS CL1024 Returned record moved here
|
Copyright © 2011 CA.
All rights reserved.
|
|