View previous topic :: View next topic
|
Author |
Message |
sandhyaimmadi
New User
Joined: 18 Aug 2008 Posts: 50 Location: Bangalore
|
|
|
|
Hi,
We have one sequential file.
We are not sure of how many thousands or millions of records it has.
If I have to process last 200 records.What needs to be done.
Please suggest.
Thanks. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
What I would suggest is..
Provide this file to Utility like DFSORT get only last 200 records in other file
provide that file to your cobol program for processing...
I am very sure that this is not business requirement and is homework or something you want to tryout....
There is also possible solution in cobol by reading file only once but as I said I would prefer earlier one... |
|
Back to top |
|
|
sandhyaimmadi
New User
Joined: 18 Aug 2008 Posts: 50 Location: Bangalore
|
|
|
|
How to get last 200 records using DFSORT? |
|
Back to top |
|
|
Pravesh
New User
Joined: 30 Jul 2009 Posts: 32 Location: Gurgaon
|
|
|
|
If you have FileAid tool then you can copy 200 records from last and feed the same into your program.
other methos is using DFSORT you can add SEQ no to your file using INREC . You can have details at
www.ibmmainframes.com/about14136.html
then use sort card like
Code: |
//SYSIN DD *
SORT FIELDS=COPY,
SKIPREC=X
|
where X = Total record - 200
Thanks,
Pravesh |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Quote: |
How to get last 200 records using DFSORT? |
Here is DFSORT\ICETOOL step to give last 200 records from the file...
Code: |
//S1 EXEC PGM=ICETOOL
//SYSOUT DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//IN DD DSN=YOUR INPUT HERE
//OUT DD DSN=YOUR OUTPUT HERE
//TOOLIN DD *
SUBSET FROM(IN) TO(OUT) KEEP INPUT LAST(200)
/*
|
|
|
Back to top |
|
|
sandhyaimmadi
New User
Joined: 18 Aug 2008 Posts: 50 Location: Bangalore
|
|
|
|
Hi Pravesh,
How can we know the last seqnumber that is generated?
We should know this inorder to access last 200 records.
Thanks,
Sandhya. |
|
Back to top |
|
|
Pravesh
New User
Joined: 30 Jul 2009 Posts: 32 Location: Gurgaon
|
|
|
|
Hi Sandhya
FYI whenever we execute DFSORT using any input file, we have information like how many record processed in ouput msgs.
hope it will help you.
Thanks,
Pravesh |
|
Back to top |
|
|
sandhyaimmadi
New User
Joined: 18 Aug 2008 Posts: 50 Location: Bangalore
|
|
|
|
Thanks Pravesh,
I will try it out.
Right now, I have tried using ICETOOL which Escapa has given.
It is working. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
If you can use FileAid, use the following. It'sa lot faster. It reads the file backward.
Code: |
//COPYKEY EXEC PGM=FILEAID
//DD01 DD DSN=YOUR.input.FILE
//DD01O DD DSN=file.contains.high.key
//SYSIN DD *
$$DD01 COPYBACK OUT=2000
/*
//*
//NEXT EXEC PGM=....
//HIGHKEY DD DSN=file.contains.high.key
//etc.... |
|
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
sandhyaimmadi wrote: |
We have one sequential file.
We are not sure of how many thousands or millions of records it has.
If I have to process last 200 records.What needs to be done. |
Millions - that's attractive. Is the file on tape? If yes, look at REVERSE verb in COBOL Manual. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Many files that run into millions of records on "tape" are also multi-volume - which won't work with REVERSE. . . |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
Quote: |
If I have to process last 200 records.What needs to be done. |
the safest thing ... fire the idiot who set the stupid requirement |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
dick scherrer wrote: |
Hello,
Many files that run into millions of records on "tape" are also multi-volume - which won't work with REVERSE. . . |
REVERSE "might" work if you specify DCB=OPTCD=B and VOL=SER=xxxxxx (where xxxxxx is the last volume serial number of the set ). Of course, that "assumes" that there will be 200 records on the last volser. If not, then the REVERSE technique with OPTCD=B will not work.
DCB=OPTCD=B requests the O/S to ignore the fact that the first reel of input is NOT the first reel of the dataset, and to also ignore the fact that the last specified reel may contain an EOV but not an EOF.
Note: a caution: DCB=OPTCD=B will not work if any OPTCD's were coded in the program source. |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
I though you COBOL guys long ago stated on this forum that REVERSE had not been supported for quite some time. Did I mis-interpret this statement? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
From the COBOL Language Reference manual:
Quote: |
REVERSED
Valid only for sequential single-reel files. REVERSED is not valid for VSAM files.
If the concept of reels has no meaning for the storage medium (for example, a direct access device), the REVERSED and NO REWIND phrases do not apply.
NO REWIND
Valid only for sequential single-reel files. It is not valid for VSAM files. |
OPEN REVERSED is obsolete according to the COBOL standards committee. The option has not been made obsolete by IBM in its COBOL (so far). |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Kevin,
From the Enterprise Language Reference:
Quote: |
REVERSED
Valid only for sequential single-reel files. REVERSED is not valid for VSAM files.
If the concept of reels has no meaning for the storage medium (for example, a direct access device), the REVERSED and NO REWIND phrases do not apply. |
Due to sheer volume, i've not used this in years. . . Of course, i also don't have a need to read the last few records of a many million record dataset. . . |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Making a subset of the last 200 records with ICETOOL seems to work, the operation can be automated, which most of the REVERSE reading JCL techniques can't, at least not in all cases.
If the original dataset resided on tape, the subset can supposedly be written to DASD storage, speeding up the processing.
If the requirement for last 200 records are not fixed, the limit should be expressed in terms of some identification key in the data. I assume the sequence of the data in the original dataset is known. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
To be very honest, this thread does really sound like a requirement to be implemented in production, is it a real requirement - I'd question.
On ther other hand, if the thread does not qualify for the question in above two lines, one should be better off by using ICETOOL or File-Aid options of doing it. I ran into such things copule of times and I used the file-aid to do that BUT then that was to do with "on the fly analysis" for some production-bug. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
I always read my hebrew papers/books backwards.
The strange thing is hebrew movies never start at the end. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
PeterHolland wrote: |
I always read my hebrew papers/books backwards.
The strange thing is hebrew movies never start at the end. |
But the dialogue is spoken backwards? |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Not yet Kjeld. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Nah, I wouldn't be able to tell anyway |
|
Back to top |
|
|
|