Example of a Dynamic Allocation Request
The example in Figure 1 is a dynamic allocation request allocating SYS1.LINKLIB with a status of SHARE. It also requests that dynamic allocation returns the ddname associated with SYS1.LINKLIB.
Figure 2 shows the parameter list
that is built from the DYNALLOC invocation in Figure 1.
Figure 1. Example of a Dynamic Allocation Request
DYN CSECT
USING *,15
STM 14,12,12(13)
BALR 12,0
BEGIN DS 0H
USING BEGIN,12
LA 0,50 AMOUNT OF STORAGE REQUIRED FOR THIS REQUEST.
GETMAIN R,LV=(0) GET THE STORAGE NECESSARY FOR THE REQUEST.
LR 8,1 SAVE THE ADDRESS OF THE RETURNED STORAGE.
USING S99RBP,8 ESTABLISH ADDRESSABILITY FOR S99RBP DSECT.
LA 4,S99RBPTR+4 POINT FOUR BYTES BEYOND START OF S99RBPTR.
USING S99RB,4 ESTABLISH ADDRESSABILITY FOR RB DSECT.
ST 4,S99RBPTR MAKE 'RBPTR' POINT TO RB.
OI S99RBPTR,S99RBPND TURN ON THE HIGH-ORDER BIT IN RBPTR.
XC S99RB(RBLEN),S99RB ZERO OUT 'RB' ENTIRELY.
MVI S99RBLN,RBLEN PUT THE LENGTH OF 'RB' IN ITS LENGTH FIELD.
MVI S99VERB,S99VRBAL SET THE VERB CODE FIELD TO ALLOCATION FUNCTION.
LA 5,S99RB+RBLEN POINT PAST 'RB' TO START OF TUP LIST.
USING S99TUPL,5 ESTABLISH ADDRESSABILITY FOR TEXT UNIT PTRS.
ST 5,S99TXTPP STORE ADDRESS OF TUP LIST IN THE RB.
LA 6,DSNTU GET ADDRESS OF FIRST TEXT UNIT
ST 6,S99TUPTR AND STORE IN TUP LIST.
LA 5,S99TUPL+4 GET ADDRESS OF NEXT TUP LIST ENTRY.
LA 6,STATUSTU GET ADDRESS OF SECOND TEXT UNIT
ST 6,S99TUPTR AND STORE IN TUP LIST.
LA 6,S99TUPL+8 POINT PAST END OF TUP LIST.
USING S99TUNIT,6 ESTABLISH ADDRESSABILITY TO TEXT UNIT.
LA 5,S99TUPL+4 GET ADDRESS OF NEXT TUP LIST ENTRY.
ST 6,S99TUPTR STORE ADDRESS OF TEXT UNIT IN TUP LIST.
OI S99TUPTR,S99TUPLN TURN ON HIGH-ORDER BIT IN LAST TUP LIST ENTRY.
MVC S99TUNIT(14),RETDDN MOVE RETURN DDNAME TEXT UNIT TO PARM AREA.
LR 1,8 PUT ADDRESS OF REQUEST BLOCK POINTER IN REG 1.
DYNALLOC INVOKE DYNALLOC TO PROCESS THE REQUEST.
LM 14,12,12(13)
BR 14 RETURN TO CALLER.
RBLEN EQU (S99RBEND-S99RB)
DSNTU DC AL2(DALDSNAM)
DC X'0001'
DC X'000C'
DC C'SYS1.LINKLIB'
STATUSTU DC AL2(DALSTATS)
DC X'0001'
DC X'0001'
DC X'08'
RETDDN DC AL2(DALRTDDN)
DC X'0001'
DC X'0008'
DS CL8
IEFZB4D0
IEFZB4D2
DYN CSECT
END
Note the concepts that the example illustrates:
- You need to request storage via the GETMAIN or STORAGE macro for
the request block and the DALRTDDN text unit, because DYNALLOC modifies
them. The DALDSNAM and DSLSTATS text units can be in static storage
in your program. In the example, the GETMAIN request is for 50 bytes, derived as follows:
- Bytes
- Purpose
- 4
- Pointer to the request block.
- 20
- Request block space.
- 12
- Four bytes each for three text unit pointers.
- 14
- Text unit space for the requested return of the ddname.
- IEFZB4D0 provides DSECTs that map the parameter list structure.
- The example uses IEFZB4D2 mnemonics in the text unit keys. For a complete list of the fields mapped by the IEFZB4D2 mapping macro, see z/OS MVS Data Areas in the z/OS Internet library.
Figure 2 shows the parameter list that results from the code in Figure 1. It is the request block structure needed to allocate data set SYS1.LINKLIB with a disposition of SHARE, and to return the ddname assigned by DYNALLOC.
Figure 2. Parameter List Resulting
from Dynamic Allocation Example