About deallocate dataset



TSO Programming, ISPF, SDF, SDSF and PDF, FTP, TCP/IP Concepts, SNA & SNA/IP etc...

About deallocate dataset

Postby Pumpkin » Mon May 16, 2011 11:55 am

hi,
i have some confused about TSO Free command operands file and dataset, are they the same function,whichever i use is ok ? or what condition to use ?
i ran some test in rexx,

1,fisrt example, one file allocate to one ddname, so at then end of code, i use "free fi(myindd)" or "free da(CUSTOMER.MASTER)" , it works fine, resubmit wouldn't be error.
 /*rexx*/                                 
 "alloc da(CUSTOMER.MASTER) fi(myindd) old"
 if rc=0 then                             
   do                                     
   "execio * diskr myindd (finis"         
    do i=1 to queued()                     
      pull sth                             
      say sth                             
    end                                   
   end                                     
 "free da(CUSTOMER.MASTER)"               
 exit                                     


2, second example, two file alloc to one ddname,
if i use "free da(CUSTOMER.MASTER,COPY.MASTER)" , after display two files,it will say:
"DATA SET userid.CUSTOMER.MASTER NOT FREED, MEMBER OF CONCATENATION
DATA SET userid.COPY.MASTER NOT FREED, MEMBER OF CONCATENATION"
resubmit will be error.
if i use "free fi(myindd)" , i will work fine.
 
/*rexx*/                                             
 "ALLOC DA(CUSTOMER.MASTER,COPY.MASTER) FI(MYINDD) OLD"
 if rc=0 then                                         
   do                                                 
   "execio * diskr myindd (finis"                     
    do i=1 to queued()                                 
      pull sth                                         
      say sth                                         
    end                                               
   end                                                 
 "free da(CUSTOMER.MASTER,COPY.MASTER)"               
 exit                                                 


3, third exaple, one file allocate to two ddname, and i use "free fi(myindd,mydd) " or "free da(CUSTOMER.MASTER)" both works fine,resubmit wouldn't be error.
another question, i use "old" operand, it should be exclusive use, i think the second allocate should fail, but it doesn't .why?


 /*rexx*/                                         
 "ALLOC DA(CUSTOMER.MASTER) FI(MYINDD) old"       
 if rc=0 then                                     
   do                                             
   "execio * diskr myindd (finis"                 
    do i=1 to queued()                           
      pull sth                                   
      say sth                                     
    end                                           
   end                                           
 say "------------------------------------------"
 "ALLOC DA(customer.MASTER) FI(MYDD) old"         
 if rc=0 then                                     
   do                                             
   "execio * diskr mydd (finis"                   
    do i=1 to queued()                           
      pull sth                                   
      say sth                                     
    end                                           
   end                                           
 "free fi(myindd,mydd) "                         
 exit                                             
-------------------
Pumpkin
Pumpkin
 
Posts: 55
Joined: Sat Mar 05, 2011 9:12 am
Has thanked: 0 time
Been thanked: 0 time

Re: About deallocate dataset

Postby enrico-sorichetti » Mon May 16, 2011 12:53 pm

when a command argument consists of a list
<generally> all the element list are considered as atomic unrelated entities

the rules for the free command just follow that convention
when freeing by dataset using a dataset list each dataset is processed atomically with no concern for the other datasets in the list

so when checking for a possible concatenation it just check for a YES/NO
checking for an overall congruence would be asking too much

using for the free the <list> approach is just a shorthand to avoid multiple free
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3002
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: About deallocate dataset

Postby steve-myers » Mon May 16, 2011 5:38 pm

In this sequence -

ALLOCATE FILE(A) DATASET(B C) OLD
FREE DATASET(B)

What I think happens is the system goes through your allocations looking for all allocations of dataset B and tries to free them. It can't free "file" A for the reason stated by the system. There is no "fix;" the system is working as it is designed; it won't break the concatenation because you are not saying very explicitly you want it to break the concatenation. This sequence works because you are saying you want to free the entire concatenation, not just part of the concatenation.

ALLOCATE FILE(A) DATASET(B C)
FREE FILE(A)

In this sequence -

ALLOCATE FILE(A) DATASET(B) OLD
ALLOCATE FILE(A) DATASET(B) OLD

the system effectively ignores the second ALLOCATE command because it deduces you've already done the allocation. It will reject the second ALLOCATE command in this sequence.

ALLOCATE FILE(A) DATASET(B)
ALLOCATE FILE(A) DATASET(C)

because "file" A is already used. You can do this sequence -

ALLOCATE FILE(A) DATASET(B)
ALLOCATE FILE(A) DATASET(C) REUS

In the second ALLOCATE command the system unconditionally does what amounts to -

FREE FILE(A)

(and it will not complain if "file" A is not actually allocated) before it tries the actual allocation.

Many shops wrote commands like this -

CONCAT (A B C)
DECONCAT A

to use in this sequence -

ALLOCATE FILE(A) DATASET(D)
ALLOCATE FILE(B) DATASET(E)
ALLOCATE FILE(C) DATASET(F)
CONCAT (A B C)
...
DECONCAT A
FREE FILE(A B C)

before IBM changed the ALLOCATE command to do an implied concatenation, which was not possible to do back in the days of MVT. This CONCAT command was relatively easy to write using either IKJDAIR dynamic allocation before MVS or MVS dynamic allocation. Notice that ALLOCATE FILE(A) DATASET(B C) doe this under the covers: ALLOCATE FILE(A) DATASET(B); ALLOCATE DATASET(C) (and remember the "file" name);CONCAT (A "file" allocated for dataset C).
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: About deallocate dataset

Postby Pumpkin » Wed May 18, 2011 5:56 pm

thanks for reply!
-------------------
Pumpkin
Pumpkin
 
Posts: 55
Joined: Sat Mar 05, 2011 9:12 am
Has thanked: 0 time
Been thanked: 0 time


Return to TSO & ISPF

 


  • Related topics
    Replies
    Views
    Last post