Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Read the contents of dataset one by one into a stem Variable
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    Post subject:
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: 1224
Location: Israel

PostPosted: Thu Jun 11, 2009 3:04 am    Post subject:
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    Post subject: Reply to: Read the contents of dataset one by one into a ste
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    Post subject: Reply to: Read the contents of dataset one by one into a ste
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Thu Jun 11, 2009 12:05 pm    Post subject: Reply to: Read the contents of dataset one by one into a ste
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: 8593
Location: Back in jolly old England

PostPosted: Thu Jun 11, 2009 12:15 pm    Post subject:
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: 1224
Location: Israel

PostPosted: Thu Jun 11, 2009 2:29 pm    Post subject: Reply to: Read the contents of dataset one by one into a ste
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm
No new posts CICS VSAM RLS READ akodakka CICS 3 Tue Oct 04, 2016 3:09 pm
No new posts Allocate dataset withour BLKSIZE Susanta CLIST & REXX 2 Thu Sep 22, 2016 11:51 am
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us