then Free the file. This can be repeated in a single run of the program
as many times as needed.
01 WS-DYNAMIC-ALLOCATIONS.
05 WS-ALLOCATE.
10 FILLER PIC X(28)
VALUE 'ALLOCATE F(JOBPROC) DSNAME('''.
10 FILLER PIC X(20)
VALUE 'SDEV.PROD.P.PROCLIB('.
10 MEMBER-NAME PIC X(8) .
10 FILLER PIC X(7)
VALUE ')'') SHR'.
05 WS-DEALLOCATE PIC X(15)
VALUE 'FREE F(JOBPROC)'.
* WORK AREA'S FOR TSO INTERFACING
01 TSO-LINK PIC X(8) VALUE 'TSOLNK'.
01 TSO-FLAGS PIC S9(9) COMP VALUE 257.
01 TSO-LENGTH PIC S9(9) COMP VALUE 0.
01 TSO-RC PIC S9(9) COMP VALUE 0.
01 TSO-REASON PIC S9(9) COMP VALUE 0.
01 TSO-ABEND PIC S9(9) COMP VALUE 0.
/****************************************************************
* DYNAMICALY ALLOCATE FILE THROUGH TSO SERVICES
*****************************************************************
8000-TSO-ALLOCATE.
MOVE LENGTH OF WS-ALLOCATE TO TSO-LENGTH.
CALL TSO-LINK USING TSO-FLAGS WS-ALLOCATE TSO-LENGTH
TSO-RC TSO-REASON TSO-ABEND.
8000-EXIT. EXIT.
/****************************************************************
* DYNAMICALY DEALLOCATE FILE THROUGH TSO SERVICES
*****************************************************************
8100-TSO-DEALLOCATE.
MOVE LENGTH OF WS-DEALLOCATE TO TSO-LENGTH.
CALL TSO-LINK USING TSO-FLAGS WS-DEALLOCATE TSO-LENGTH
TSO-RC TSO-REASON TSO-ABEND.
8100-EXIT. EXIT.
The Program needs to run under batch TSO services similar to a DB2
program
//STEP010 EXEC PGM=IKJEFT01
//SYSTSPRT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSTSIN DD *
CALL *(MYPROG)