Hey guys, me again on my rexx adventure and needing some quick insight from all of you experts, hope not to bother you much this time.. so the deal is that I can't get a FREE DD command to work when to free/close a generated(last) member out of a LMDINIT command. I've tried several places already so as a last resort I really hope you allow me to bother you a little bit.
Initially whenever an empty member is generated (no more datasets are read) then it will do a free and deletion of this last empty member, now if we proceed below you will find thse:
DATAsap = cntid3//10000
IF DATAsap = 0 THEN DO
"EXECIO 0 DISKW "SRCSAP""mbn" (FINIS"
"EXECIO 0 DISKW "TGTSAP""mbn" (FINIS"
and more below a QUEUE is executed to generate a job containing a few jcl rows for each new SRCSAP"mbn" and TGTSAP"mbn" that is generated.
Once all datasets are read and SRCSAP"mbn" , TGTSAP"mbn" and CLNSAP"mbn" are created the program ends and invoke LIST_DS. Problem I'm facing is that once the program completes, if I execute CLNSAP job it complains that both DB2.CLONE."SID".CNTL and DB2.CLONE."SID".JCL are still opened and last SRCSAP , TGTSAP were not freed.
Lets say when more than one STCSAP/TGTSAP are generated, the free DD works but the last one generated never gets really freed up.
I hope it does make sense what I'm trying to accomplish.
So below is the code;
ALLOC_DS: /* This procedure will create the new dataset that will store
Source / Target files and also FRRECOV jobs */
if emptymember = 0 then do
"ISPEXEC LMDLIST LISTID("ID3") OPTION(FREE)"
/* FETCH STEP 3: Will fetch data based on SAPSID parsed argument */
SAY "Creating members (SRCSAP and TGTSAP) to list SOURCE DB2 SAP Application ta
SAY "Loading dataset list in SRCSAP/TGTSAP members. PLEASE BE PATIENT"
/* LIST_DS will show on screen the new members generated
For Source and Target files */
SAY "LISTING NEWLY CREATED MEMBERS"
"LISTDS DB2.CLONE."SID".CNTL MEMBERS"
"LISTDS DB2.CLONE."SID".JCL MEMBERS"
Joined: 30 Nov 2013 Posts: 870 Location: The Universe
FREE DDname(...) (as opposed to File(...)) has been valid for a long time. Like most old timers, i rarely use FREE DD, and do use FREE F. Actually I use ALLOCATE FILE(...) REUSE (rather than FREE F(...);ALLOC FILE(...) just to use one command.
The actual code only needs to look at the ZZ1 (for FILE or DDNAME) PDE, or the ZZ2 (for DATASET or DSNAME) PDE; the keyword is immaterial.
Now you may say, but doesn't the PROMPT keyword require the terminal user to enter a value? Yes, but only if the FILE/DDNAME or DATASET/DSNAME keyword is entered, so it won't prompt for a data set name when FREE DDNAME is entered by the terminal user.
Just some notes about the terminology. In the parse macros, a PCE (Parameter Code Entry) is the data in the PCL (Parameter Control List) CSECT constructed by the parse macros; a PDE (Parameter Descriptor Entry) is the data returned by IKJPARS in the PDL (Parameter Descriptor List) DSECT also constructed by the parse macros.
Hi Folks, first of all I'd like to say I appreciate all the feedback and valuable insights. It's weird thou that somehow I couldn't still figure this out .. whatever place I put the FREE listid :
"ISPEXEC LMDLIST LISTID("ID3") OPTION(FREE)"
even thou the datasets are not freed after they are generated, if I put LMDLIST LISTID free inside the loop the program just doesn't complete at all, if I put at the beginning of the code (as it shows in my first post) members SRCSAP1 and TGTSAP1 are kept opened just like CNTL and JCL datasets, which forces me to do a TSO ISRDDN and hit F in front of those (first I need to free members SAP1 and then the datasets).
I was thinking that perhaps, after LIST_DS function I could add a ISPEXEC to close the datasets ? One issue I had with that is that the program ends in error saying that FREE is not a valid dialog command .. I've been trying for days but still have the same outcome.. feel like I'm running out of ideas
I am talking about a missing LMDFREE, the companion of your ISPEXEC LMDINIT, not LMDLIST FREE.
A few more comments:
I assume that variables SRCSAP, TGTSAP and mbn has been defined prior to entering ALLOC_DS, otherwise the ddname in the free commands would be 9 byte long.
You should have quotes around the 'delete' commands.
I don't think that you need to increase the DDname qualifier like "SRCSAP""mbn", seems to me that you are allocating and freeing the ddname set in each loop iteration. And since you do ALLOCATE .. REUSE, you might get away with just using i.e.. DDname SRCSAP hardcoded.