IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Add a step counter in a stack ?


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Wed Jul 29, 2020 1:02 pm
Reply with quote

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
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Wed Jul 29, 2020 4:42 pm
Reply with quote

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.
Back to top
View user's profile Send private message
rodferrn

New User


Joined: 14 Jul 2020
Posts: 14
Location: Brazil

PostPosted: Fri Jul 31, 2020 1:55 am
Reply with quote

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                                                                         
                                                                             
"ISPEXEC LMDINIT LISTID(ID3) LEVEL(SAP"SID".DSNDBD.*)"                       
                                                                             
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                                                                     
                                                                         
Realloc:                                                                 
  "ISPEXEC LMDLIST LISTID("ID3") OPTION(FREE)"                           
  "ALLOC DD("SRCSAP""mbn") DA(DB2.CLONE.NEW."SID"("SRCSAP""mbn")) SHR"   
  "EXECIO * DISKW  "SRCSAP""mbn" (STEM DATAsap. FINIS"                   
  "FREE DD("SRCSAP""mbn")"                                               
  mbn = mbn + 1                                                         
RETURN 0                                                                 
                                                                         
/* LIST_DS will show on screen the new members generated                 
           For Source and Target files                   */             
                                                                         
LIST_DS:                                                                 
 SAY "LISTING NEWLY CREATED MEMBERS"   
 "LISTDS DB2.CLONE.NEW."SID" MEMBERS"   
EXIT 0                                 
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Jul 31, 2020 3:16 pm
Reply with quote

After writing your 10,000 records you then have to remove them i.e. DROP DATASAP - as you were previously told.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts How to get a stack trace on a looping... ABENDS & Debugging 5
No new posts Return codes-Normal & Abnormal te... JCL & VSAM 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
No new posts Two input files & writing counter... DFSORT/ICETOOL 12
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
Search our Forums:

Back to Top