z/OS MVS Programming: Extended Addressability Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Example of creating, using, and deleting a data space

z/OS MVS Programming: Extended Addressability Guide
SA23-1394-00

This section contains a complete example of a how a problem program creates, establishes addressability to, uses, and deletes the data space named TEMP. The first lines of code create the data space and establish addressability to the data space. To keep the example simple, the code does not include the checking of the return code from the DSPSERV macro. However, you should always check the return codes after issuing the macro.

The lines of code in the middle of the example (under the comment "MANIPULATE DATA IN THE DATA SPACE") illustrate how, with the code in AR mode, the familiar assembler instructions store, load, and move a simple character string into the data space and move it within the data space. The example ends with the program deleting the data space entry from the access list, deleting the data space, and returning control to the caller.
DSPEXMPL CSECT
DSPEXMPL AMODE 31
DSPEXMPL RMODE ANY
         BAKR  14,0                   SAVE CALLER'S STATUS ON STACK
         SAC   512                    SWITCH INTO AR MODE
         SYSSTATE ASCENV=AR           SET GLOBAL BIT FOR AR MODE
         .
*  ESTABLISH AR/GPR 12 AS BASE REGISTER
         .
         LAE   12,0                   SET BASE REGISTER AR
         BASR  12,0                   SET BASE REGISTER GPR
         USING *,12
*  CREATE THE DATA SPACE AND ADD THE ENTRY TO THE ACCESS LIST
         .
         DSPSERV CREATE,NAME=DSPCNAME,STOKEN=DSPCSTKN,                X
               BLOCKS=DSPBLCKS,ORIGIN=DSPCORG
         ALESERV ADD,STOKEN=DSPCSTKN,ALET=DSPCALET,AL=WORKUNIT
         .
         .
*  ESTABLISH ADDRESSABILITY TO THE DATA SPACE
         .
         LAM   2,2,DSPCALET           LOAD ALET OF SPACE INTO AR2
         L     2,DSPCORG              LOAD ORIGIN OF SPACE INTO GR2
         USING DSPCMAP,2              INFORM ASSEMBLER
         .
*  MANIPULATE DATA IN THE DATA SPACE
         .
         L     3,DATAIN
         ST    3,DSPWRD1              STORE INTO DATA SPACE WRD1
         .
         MVC   DSPWRD2,DATAIN         COPY DATA FROM PRIMARY SPACE
*                                     INTO THE DATA SPACE
         MVC   DSPWRD3,DSPWRD2        COPY DATA FROM ONE LOCATION
*                                     IN THE DATA SPACE TO ANOTHER
         MVC   DATAOUT,DSPWRD3        COPY DATA FROM DATA SPACE
*                                     INTO THE PRIMARY SPACE
         .
*  DELETE THE ACCESS LIST ENTRY AND THE DATA SPACE
         .
         ALESERV DELETE,ALET=DSPCALET    REMOVE DS FROM AL
         DSPSERV DELETE,STOKEN=DSPCSTKN  DELETE THE DS
         .
         PR                            RETURN TO CALLER
         .
DSPCNAME DC   CL8'TEMP    '            DATA SPACE NAME
DSPCSTKN DS   CL8                      DATA SPACE STOKEN
DSPCALET DS   F                        DATA SPACE ALET
DSPCORG  DS   F                        DATA SPACE ORIGIN RETURNED
DSPCSIZE EQU  10000000                 10 MILLION BYTES OF SPACE
DSPBLCKS DC   A((DSPCSIZE+4095)/4096)  NUMBER OF BLOCKS NEEDED FOR
*                                      A 10 MILLION BYTE DATA SPACE
DATAIN   DC   CL4'ABCD'
DATAOUT  DS   CL4
*
DSPCMAP  DSECT                         DATA SPACE STORAGE MAPPING
DSPWRD1  DS    F                       WORD 1
DSPWRD2  DS    F                       WORD 2
DSPWRD3  DS    F                       WORD 3
         END

Note that you cannot code ACCESS=PRIVATE on the ALESERV macro when you request an ALET for a data space; all data space entries are public.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014