Something like (not tested, from the top of my head).
Notes:
1 I use BPXWDYN for allocation so that I can retrieve a generated DDname.
2. I use count= 1 to 999999 to save a coount-up operation. not a big saving but still.
3. When count is divisable with 10000 then a reallocation is done
4. I leave the loop for LMDLIST rc<>0, which I find simpler.
I hope this is somewhat what yo are loooking for.
Code:
mbrn=0
ddname=''
Call Realloc
DO count=1 to 999999
"ISPEXEC LMDLIST LISTID("ID3") OPTION(LIST) DATASET(DSNSAP)"
IF RC <> 0 THEN leave
if count//10000=0 then call realloc
DATAsap.count = DSNSAP
END
cc=Bpxwdyn('free dd('ddname')')
... some code ..
ReAalloc:
if ddname<>'' then cc=Bpxwdyn('free dd('ddname')')
mbrn=mbrn+1
cc=Bpxwdyn('alloc da(dataset.name(mbr'mbrn')) shr rtddn(ddname)')
return 0
Just realized that, despite my general preference for BPXWDYN over ALLOCATE, in this case "ALLOCATE DA('dataset.name(mbr"mbrn")) DD(ddname) SHR REUSE" is the simpler option.
Hey Willy, thanks again for your reply, but I'm still having issues to write down the logic to split my DSNDBD files into multiple members.
Whenever you guys give me a sample, what I try to do is, instead of simply copy and paste I try to write down my own logic based on the provided code, in that way, plus reading manuals is the way I'm using to learn rexx (and programming actually).
Now, allow me to paste the entire logic below and explain a little bit (with the current logic I have 2 issues that I'm trying to adress).
So the logic basically asks for a SID (subsystem id) based on that SID, a dataset will be created and then LMDINIT / LMDLIST comes into play to list all datasets based on SAPsid.DSNDBD.** , now, using one database as example, I have 20165 DSNDBD files, so the logic has mainly 2 issues
1) Code is generating 2 members in DB2.CLONE.NEW.sid where SRCSAP1 goes from dataset number 1 to number 10.000 (which is ok) however the second member generated SRCSAP2 will copy the same datasets from row 1 to row 10.000 and continue until it reaches 20.002 (and then it stops). Now the second member is still adding the first 10k files (which were supposed to be on member 1 only).
2) Since its doing "IF count // 10001=0 THEN CALL Realloc" count goes only until 20.002 files, so its not writing all 20.165 files into the members.
Now, I have a guess about issue number 1, since I'm doing LMDINIT / LMDLIST, I think between the loop (from SRCSAP1 to SRCSAP2) the list is deleted and recreated so it will add all the 20002 datasets in member 2 ? I thought about creating a 3rd member containing the full list and then split this list into 2 new members splitting by 10.000 each ? Not sure if that would be the correct approach to follow ?
Here's the current code;
Code:
/* REXX */
SAY 'PLEASE INFORM A SUBSYSTEM ID NAME E.G. PWS , YPE , YPC '
SAY 'Member number is not required (Do not use E.G. YPE1 , YPC2) '
PULL SID
IF SID = '' THEN DO
SAY 'MISSING SUBSYSTEM NAME, PROGRAM WILL END'
EXIT 16
END
ELSE SAY "DATASET DB2.CLONE.NEW."SID" WILL BE ALLOCATED"
CALL ALLOC_DS
ALLOC_DS: /* This procedure will create the new dataset that will store
Source / Target files and also FRRECOV jobs */
DSN = SYSDSN(DB2.CLONE.NEW.""SID"") /* When SID specified, create dataset */
IF DSN = 'OK' THEN DO /* If DSN already exist, program will exit */
SAY "DATASET ALREADY EXISTS. EXITING PROGRAM, GOODBYE!"
EXIT 4
END
ELSE /* If DSN does not exist, create and continue exec */
"ALLOC DA(DB2.CLONE.NEW."SID") NEW REU RECFM(F B) LRECL(80)",
"DSORG(PO) SPACE(10,10) CYLINDERS UNIT(SYSDA) DSNTYPE(LIBRARY)"
SAY "DATASET DB2.CLONE.NEW."SID" ALLOCATED SUCCESSFULY "
SAY
SAY
SAY
UPDATE_DS:
/* UPDATE_DS procedure will list all DB2 source files and create a member
for each set of datasets */
/* FETCH STEP 3: Will fetch data based on SAPSID parsed argument */
SAY "CREATING MEMBER (SRCSAP) TO LIST SOURCE DB2 DATASETS"
SAY "CREATING MEMBER (TGTSAP) WITH RENAME FROM SRCSAP FILE"
SAY
SAY "LOADING DATASET LIST IN SRCSAP MEMBER. PLEASE BE PATIENT"
SAY
mbn = 0
CALL Realloc
DO count = 1 to 999999
"ISPEXEC LMDLIST LISTID("ID3") OPTION(LIST) DATASET(DSNSAP)"
IF RC <> 0 THEN CALL LIST_DS
IF count // 10001=0 THEN CALL Realloc
DATAsap.count = DSNSAP
END