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

Read the contents of dataset one by one into a stem Variable


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

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Wed Jun 10, 2009 9:37 pm
Reply with quote

Multiple Datasets are input to REXX. I have to read the contents of the data set one by one into a stem variable

Code:
//DDIN     DD DSN=ABC.DEF.GHI(TEST1),DISP=SHR
//         DD DSN=ABC.DEF.GHI(TEST1),DISP=SHR
//         DD DSN=ABC.DED.FGH(AB12),DISP=SHR


Code:
"EXECIO * DISKR DDIN (STEM Code. FINIS "


How should I modify the above code, so that it reads the contents of the data set one by one into a stem variable N times.

Code:
Contents of ABC.DEF.GHI(TEST1)
Read 1
Contents of ABC.DEF.GHI(TEST1)
Read 2
Contents of ABC.DED.FGH(AB12)
Read 3
Back to top
View user's profile Send private message
genesis786

Active User


Joined: 28 Sep 2005
Posts: 210
Location: St Katherine's Dock London

PostPosted: Wed Jun 10, 2009 10:44 pm
Reply with quote

what do you exactly mean by

Quote:
so that it reads the contents of the data set one by one into a stem variable N times.


if i understand you correctly, then you need three DD cards, three EXECIO * DISKR statements.

and why TEST1 two times ?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Jun 11, 2009 3:04 am
Reply with quote

Do not concatenate the files, make a list of them:
Code:
//DDIN     DD *
ABC.DEF.GHI(TEST1)
ABC.DEF.GHI(TEST1)
ABC.DED.FGH(AB12)

Get the list:
Code:
"EXECIO * DISKR DDIN (STEM ListOfFiles. FINIS"

And process files one by one:
Code:
Do X = 1 To ListOfFiles.0
   "ALLOC FI(DDIN2) DA('"ListOfFiles.X"') SHR REUSE"
   "EXECIO * DISKR DDIN2 (STEM Lines. FINIS"
   "FREE FI(DDIN2)"
   Call Main_File_Process
End


As I have the REUSE option in ALLOC, I think I can take the FREE out of the loop and do it once after the end.
Back to top
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Thu Jun 11, 2009 11:46 am
Reply with quote

Hi genesis786


Quote:
what do you exactly mean by

I mean that the EXECIO must read the contents of the data set one by one into a stem variable N(It should read 5times if the input is 5 datasets) times.

I need a break or a identification that the EXECIO have read the first dataset and gonna start reading the second.

Quote:
if i understand you correctly, then you need three DD cards, three EXECIO * DISKR statements.

I can't gauge, how many datasets will be the input tho the REXX, it may range from 1 to N.

Quote:
and why TEST1 two times ?

It should have been
Code:
//DDIN     DD *
ABC.DEF.GHI(TEST1)
ABC.DEF.GHI(TEST2)
ABC.DED.FGH(AB12)
Back to top
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Thu Jun 11, 2009 11:52 am
Reply with quote

Hi Marso

Quote:
Code:
//DDIN     DD *
ABC.DEF.GHI(TEST1)
ABC.DEF.GHI(TEST1)
ABC.DED.FGH(AB12)


Instead of the above, is it possible to do like the below, any way of doing like this?
Code:
//DDIN     DD DSN=ABC.DEF.GHI(TEST1),DISP=SHR
//         DD DSN=ABC.DEF.GHI(TEST1),DISP=SHR
//         DD DSN=ABC.DED.FGH(AB12),DISP=SHR
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Jun 11, 2009 12:05 pm
Reply with quote

why insist?? You already got a reply

a concatenation of datasets will always look like a single dataset

EOF processing will take place only at eof of the last dataset, not in between
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Jun 11, 2009 12:15 pm
Reply with quote

Look HERE for something that may help.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Jun 11, 2009 2:29 pm
Reply with quote

If you really want ONE input file, there is another possibility:
Code:
//INDD   DD   *                                   
*** TEST1 ***
//       DD   DISP=SHR,DSN=ABC.DEF.GHI(TEST1)
//       DD   *                                   
*** TEST2 ***
//       DD   DISP=SHR,DSN=ABC.DEF.GHI(TEST2)
//       DD   *                                   
*** AB12 ***
//       DD   DISP=SHR,DSN=ABC.DED.FGH(AB12)

Read everything in one block:
Code:
"EXECIO * DISKR DDIN (STEM Code. FINIS "

Then split the big stem into as many little stems:
Code:
ListMem = ''
Do X = 1 To Code.0
   If Left(Code.X,3) = '***' Then Do
      CurrentMem = Word(Code.X,2)
      ListMem = ListMem CurrentMem
      Y = 0
      Iterate
   End
   Y = Y + 1
   Code.CurrentMem.Y = Code.X
   Code.CurrentMem.0 = Y
End

When this loop finishes, you have 3 stems:
1. Code.TEST1.1 to Code.TEST1.n contains TEST1
2. Code.TEST2.1 to Code.TEST2.p contains TEST2
3. Code.AB12.1 to Code.AB12.q contains AB12
n, p and q are kept in Code.xxxx.0

and a list, necessary to reconstruct the stem names:
ListMem contains "TEST1 TEST2 AB12"

1st solution proposed was nicer.
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 Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Allocated cylinders of a dataset DB2 12
Search our Forums:

Back to Top