Rexx - Concatenate Number of Datasets with a Pattern and Read Data

Thursday, May 16, 20133comments

Suppose You have a List of PS Datasets with a naming Pattern. In Your Rexx Program You want to read the data of the concatenated list of Datasets the same way as You would do by giving a list of DD DSN= statements with the same DDName in a JCL. To Achieve this, You can use the LMDINIT and LMDLIST ISPEXEC services in Your Rexx Program.


The data set list service (LMDLIST) generates and uses an internal list of data set names associated with a unique data set list ID (dslist ID) obtained from the LMDINIT service.
The names in the internal list can be passed to a dialog with data set information (if specified) using two options:

  • The LIST option returns the information one name at a time through the function pool variables.
  • The SAVE option writes the names and information to a data set.

The internal list is not dynamic. Data sets created after the invocation of the LMDINIT service will not added to the list. To update the list to include new data set names, use the LMDFREE service to release the current dslist ID and reissue the LMDINIT and LMDLIST services, or reissue the LMDINIT and LMDLIST services using a different dslist ID.

The example program is shown below.


/* REXX */                                                              
CONCLIST=""                                                              
ADDRESS ISPEXEC                                                          
/* N.B: DATASET NAME TEMPLATE NOT BOUNDED BY SINGLE QUOTES */            
"LMDINIT LISTID(LISTID) LEVEL(AIW.AIWXR*.**.DATA*)"                            
DATASET=""                                                              
DO FOREVER                                                              
   OK="4 8";"LMDLIST LISTID("LISTID") DATASET(DATASET)"                  
   IF RC>0 THEN DO                                                      
      LEAVE                                                              
   END                                                                
   CONCLIST=CONCLIST" '"STRIP(DATASET,"B")"'"                            
END                                                                  
CONCLIST=SUBSTR(CONCLIST,2)                                              
"LMDFREE LISTID("LISTID")"                                              
ADDRESS TSO                                                              
/* N.B: DATASET NAMES NOW BOUNDED BY SINGLE QUOTES */                    
"ALLOC FI(TEMP) DA("CONCLIST") SHR REUSE"                                
"EXECIO * DISKR TEMP (OPEN STEM REC. FINIS)"                            
"FREE FI(TEMP)"                                                          
DO R=1 TO REC.0                                                          
   SAY STRIP(REC.R,"T")                                                  
   END                                                                  
EXIT  

SAY THE INPUT FILES ARE AS BELOW:

USER       AIW.AIWXR1.DATE1.DATA  
000001 DATA1 LINE 1                                                            
000002 DATA1 LINE 2                                                            
000003 DATA1 LINE 3                                                            

USER       AIW.AIWXR5.DATE2.DATA
000001 DATA2 LINE 1                                                            
000002 DATA2 LINE 2                                                            
000003 DATA2 LINE 3                                                            

USER       AIW.AIWXR4.DATE3.DATA                           
000001 DATA3 LINE 1                                                            
000002 DATA3 LINE 2                                                            
000003 DATA3 LINE 3                                                            

When running the Output we get: 

DATA1 LINE 1 
DATA1 LINE 2 
DATA1 LINE 3 
DATA2 LINE 1 
DATA2 LINE 2 
DATA2 LINE 3 
DATA3 LINE 1 
DATA3 LINE 2 
DATA3 LINE 3 




                                
Share this article :

+ comments + 3 comments

January 17, 2017 at 11:35 PM

Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your.
Digital Marketing Company in India

Anonymous
March 9, 2017 at 9:04 PM

HI,

Is there any way to Concatenate/COPY all "A.B.*.C.D*" listed dataset into a output dataset (DASD).

else need to give all the DD in sortin to do the same :(.

Thanks in advance for any suggestion.

May 22, 2017 at 3:53 AM

Source:

Kurt Deininger / Sep 24, 2010 / http://ibmmainframes.com/about51372.html

...perhaps you have just forgotten ;o)

Post a Comment

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Atom's Arena - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger