IN rexx how to read a seq. flat file multiple times



IBM's Command List programming language & Restructured Extended Executor

IN rexx how to read a seq. flat file multiple times

Postby jscagli » Thu Feb 06, 2014 8:19 pm

Trying to write a rexx program in which i compare a portion of a record from fileA (flat file) against a portion of a record from all the records in fileB (flat file). If no match is found i then read the next record from fileA and compare it to all the records in fileB. The problem is once all the records in fileB have been read once I can't seem to read the file again. I know the rc goes from 0 to 2 once all the records are read and this causes the EOF marker to go from 'no' to 'yes'. However i do not know how to reset this so fileB can be read multiple times (until all records from fileA have been read).
jscagli
 
Posts: 8
Joined: Thu Jan 13, 2011 9:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: IN rexx how to read a seq. flat file multiple times

Postby enrico-sorichetti » Thu Feb 06, 2014 8:27 pm

pretty primitive approach

when a match is found what happens ???
are You going to modify file A or file B ???

if You describe the requirement rather than your attempt to a solution You might receive better suggestions
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: IN rexx how to read a seq. flat file multiple times

Postby jscagli » Thu Feb 06, 2014 8:40 pm

No need to get insulting. This is my first time posting a question. When a match is found the record from fileB that has the match is copied over to a separate file.
jscagli
 
Posts: 8
Joined: Thu Jan 13, 2011 9:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: IN rexx how to read a seq. flat file multiple times

Postby NicC » Thu Feb 06, 2014 9:38 pm

How big are your files? Are they sorted? What have you tried in the area of closing and re-opening the file? Have you considered using JOINKEYS within your sort product?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: IN rexx how to read a seq. flat file multiple times

Postby jscagli » Thu Feb 06, 2014 10:24 pm

FileA is about 1200 records. FileB is approx 35,000 records. They are not sorted. I am taking an eight byte field from each record in fileA and comparing it to an eight byte field in each record in fileB. When a match is found in fileB I move a copy of that record over to a separate outfile. The record in fileA must be compared to 'every' record in fileB. Then the next record in fileA is compared to every record in fileB - and so on. I guess my problem is how do I get the fileB dataset reopened after a record from fileA has has gone through all the fileB records. The fileA records are only read once. thx
jscagli
 
Posts: 8
Joined: Thu Jan 13, 2011 9:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: IN rexx how to read a seq. flat file multiple times

Postby Pedro » Thu Feb 06, 2014 10:41 pm

They are not sorted.

The first step of your rexx program should be to sort the files.

Based on the sizes of the files, I would try to only read FileB only one time.

You should index FileA something like this, which builds an array of keys in fileA:
allkeys. = 'null'
EXECIO ...  (STEM filea.
Do ix  = 1 to filea.0
  keyA = substr(filea.ix,27,8)
  allkeys.keyA = keyA
End

Then as you read in records from FileB, see if there is a match:
keyb = substr(fileb,27,8)
If  allkeys.keyb ^= 'null' Then ...
Pedro Vera
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: IN rexx how to read a seq. flat file multiple times

Postby Pedro » Thu Feb 06, 2014 10:57 pm

It sounds like you wanted to read fileB 1200 times:
1200 x 35000 = 42 million records

I think that would take you many minutes of elapsed time.
Pedro Vera
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: IN rexx how to read a seq. flat file multiple times

Postby jscagli » Thu Feb 06, 2014 11:12 pm

Both fileA and fileB could be broken down into smaller chunks if that would make any difference. I'm getting the feeling that in rexx a sequential file can only be read through once which is interesting because I know LMM services will allow you to read through all the members in a pds multiple times.
jscagli
 
Posts: 8
Joined: Thu Jan 13, 2011 9:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: IN rexx how to read a seq. flat file multiple times

Postby Pedro » Thu Feb 06, 2014 11:47 pm

However i do not know how to reset this so fileB can be read multiple times (until all records from fileA have been read).

This is a technical forum. The details of the program are important. Show us the code that reads the file until EOF and then tries again. And show us a trace.

I suspect you need to read about the FINIS parameter of EXECIO. Or possibly, use the linenum parameter (after the DD name):
EXECIO 1 DISKR MYDATA 1
Pedro Vera
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: IN rexx how to read a seq. flat file multiple times

Postby NicC » Fri Feb 07, 2014 3:15 am

With those small numbers of records you could read them all into 2 stems and then process stem a against stem b
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post