View previous topic :: View next topic
|
Author |
Message |
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
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 |
|
|
genesis786
Active User
Joined: 28 Sep 2005 Posts: 210 Location: St Katherine's Dock London
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
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 |
|
|
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Look HERE for something that may help. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
|