PDA

View Full Version : How to read members of a PF



cwscholbe@dstsystems.com
01-01-1995, 02:00 AM
First, I am not a/the programmer. Second, It has been determined that this process must read members of a PF to extract the data. No Dtaara's or .... We will be building multiple members in a PF, one per day. We need to read the last member looking for a particular record. If not found, then we need to read the 'previous' member and so on until we find what we are looking for. I'm not sure how many members we may have to read or how big each member might get. I thought that we could DSPFD the file to *OUTFILE and then read the file with the Cobol program, but is there a better way????????? Any ideas? TIA

Guest.Visitor
09-01-2000, 01:36 PM
SORT THE OUTFILE BY DATE DESCENDING, AND THEN GO THRU LOOKING FOR THE REC. ??? OR AM I MISSING SOMETHING COULD YOU DO OVRDBF MBR(*ALL) ?? BOBH

Guest.Visitor
09-01-2000, 04:13 PM
Do a RTVMBRD *LAST and get that member name, override to it with OVRDBF and call your program with a parameter to indicate if the record was found. If not found, do a RTVMBRD *PREVIOUS and specify the last member name that was searched. This will get the previous chronological member name. Repeat this process until you find the record or run out of members. Chris

cwscholbe@dstsystems.com
09-02-2000, 09:15 AM
Thanks Chris, This sounds simple enough that we just might be able to make it work. Thanks for your help. Chris P.S. No Bob, you weren't missing anything. We have always used a single member with our PF's and it was always the same name as the PF. I guess we are just too set in our ways. Thanks for your help.

Guest.Visitor
09-03-2000, 10:58 AM
Chris S, I think Bob's idea of using OVRDBF MBR(*ALL) may be better than mine. You could then starting reading from the last record in the file and read backwards until you find the desired record. When doing an OVRDBF MBR(*ALL), records are read in member sequence. If you need to know the specific member name that the record was found in, you could retrieve this from the COBOL I-O Feedback area. Chris

Guest.Visitor
09-03-2000, 06:44 PM
Take note that specifying *PREVIOUS gets you the member name immediately previous to the reference member in a "name ordered" list. To make sure you get the right sequence, you must make sure the member names reflect the sequence by which they are added to the physical file. In some of my systems, I solved the problem by incorporating a counter into the member names. This works fine unless the counter overflows. To prevent overflow, I resequence all the members every month.

Guest.Visitor
09-05-2000, 07:19 AM
Ricardo, You're correct. Specifying *PRV or *NEXT does indeed read the members by name. To get the members by creation date, an outfile is needed: DSPFD FILE(Library/File) TYPE(*MBR) OUTPUT(*OUTFILE) OUTFILE(QTEMP/Members) The outfile contains the members in ascending chronological order by creation date. Also, I suggested using OVRDBF MBR(*ALL) and positioning the file pointer to the last record in the last member and reading the file backwards. This does not work either. The statement "*HIVAL SETGT Members" will only set the file pointer to the 2nd member in the file, not the last. To read the newest member and work back to the oldest member, the outfile above must be read backwards and the corresponding member overridden. Or as Ricardo suggested, put a counter in the member name itself and then use RTVMBRD *PRV. Chris