An example of mapping a data-in-virtual object to a hiperspace
The following example shows how you would create a standard hiperspace
with a maximum size of one gigabyte and an initial size of 4K bytes.
Figure 1 shows the hiperspace with a window that begins
at the origin of the hiperspace.
Figure 1. Example of Mapping
a Data-in-Virtual Object to a Hiperspace
Initially, the window in the hiperspace and the buffer area in
the address space are both 4K bytes. (That is, the window takes up
the entire initial size of the hiperspace.) The data-in-virtual object
is a VSAM linear data set on DASD.
* CREATE A STANDARD HIPERSPACE
.
DSPSERV CREATE,TYPE=HIPERSPACE,HSTYPE=SCROLL,NAME=HS1NAME, X
STOKEN=HS1STOK,BLOCKS=(ONEGIG,FOURK),ORIGIN=HS1ORG
.
* MAP THE HIPERSPACE TO THE OBJECT
.
DIV IDENTIFY,ID=OBJID,TYPE=DA,DDNAME=OBJDD
DIV ACCESS,ID=OBJID,MODE=UPDATE
DIV MAP,ID=OBJID,AREA=HS1ORG,STOKEN=HS1STOK
.
* OBTAIN A 4K BUFFER AREA IN ADDRESS SPACE TO BE
* USED TO UPDATE THE DATA IN THE HIPERSPACE WINDOW
.
* DECLARATION STATEMENTS
.
HS1NAME DC CL8'MYHSNAME' HIPERSPACE NAME
HS1STOK DS CL8 HIPERSPACE STOKEN
HS1ORG DS F HIPERSPACE ORIGIN
ONEGIG DC F'262144' MAXIMUM SIZE OF 1G IN BLOCKS
FOURK DC F'1' INITIAL SIZE OF 4K IN BLOCKS
OBJID DS CL8 DIV OBJECT ID
OBJDD DC AL1(7),CL7'MYDD ' DIV OBJECT DDNAME
The program can read the data in the hiperspace window to a buffer area in the address space through the HSPSERV SREAD macro. It can update the data and write changes back to the hiperspace through the HSPSERV SWRITE macro. For an example of these operations, see Example of creating a standard hiperspace and using it.
Continuing the example, the following code saves the data in the
hiperspace window on DASD and terminates the mapping.
* SAVE THE DATA IN THE HIPERSPACE WINDOW ON DASD AND END THE MAPPING
.
DIV SAVE,ID=OBJID
DIV UNMAP,ID=OBJID,AREA=HS1ORG
DIV UNACCESS,ID=OBJID
DIV UNIDENTIFY,ID=OBJID
.
* PROGRAM FINISHES USING THE DATA IN THE HIPERSPACE
.
* DELETE THE HIPERSPACE
.
DSPSERV DELETE,STOKEN=HS1STOK
.