IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Processing last 200 records


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sandhyaimmadi

New User


Joined: 18 Aug 2008
Posts: 50
Location: Bangalore

PostPosted: Wed May 26, 2010 1:17 pm
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed May 26, 2010 1:53 pm
Reply with quote

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
View user's profile Send private message
sandhyaimmadi

New User


Joined: 18 Aug 2008
Posts: 50
Location: Bangalore

PostPosted: Wed May 26, 2010 2:22 pm
Reply with quote

How to get last 200 records using DFSORT?
Back to top
View user's profile Send private message
Pravesh

New User


Joined: 30 Jul 2009
Posts: 32
Location: Gurgaon

PostPosted: Wed May 26, 2010 2:24 pm
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed May 26, 2010 2:30 pm
Reply with quote

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
View user's profile Send private message
sandhyaimmadi

New User


Joined: 18 Aug 2008
Posts: 50
Location: Bangalore

PostPosted: Wed May 26, 2010 2:33 pm
Reply with quote

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
View user's profile Send private message
Pravesh

New User


Joined: 30 Jul 2009
Posts: 32
Location: Gurgaon

PostPosted: Wed May 26, 2010 2:45 pm
Reply with quote

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
View user's profile Send private message
sandhyaimmadi

New User


Joined: 18 Aug 2008
Posts: 50
Location: Bangalore

PostPosted: Wed May 26, 2010 3:31 pm
Reply with quote

Thanks Pravesh,

I will try it out.

Right now, I have tried using ICETOOL which Escapa has given.
It is working.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed May 26, 2010 4:05 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Wed May 26, 2010 4:38 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed May 26, 2010 8:48 pm
Reply with quote

Hello,

Many files that run into millions of records on "tape" are also multi-volume - which won't work with REVERSE. . .
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Wed May 26, 2010 11:28 pm
Reply with quote

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 icon_cool.gif
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Wed May 26, 2010 11:53 pm
Reply with quote

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
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu May 27, 2010 12:13 am
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu May 27, 2010 12:20 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Thu May 27, 2010 12:25 am
Reply with quote

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
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Thu May 27, 2010 3:24 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Thu May 27, 2010 3:32 pm
Reply with quote

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
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu May 27, 2010 3:45 pm
Reply with quote

I always read my hebrew papers/books backwards.
The strange thing is hebrew movies never start at the end.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Thu May 27, 2010 3:56 pm
Reply with quote

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? icon_biggrin.gif
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu May 27, 2010 3:59 pm
Reply with quote

Not yet Kjeld. icon_lol.gif
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Thu May 27, 2010 4:01 pm
Reply with quote

Nah, I wouldn't be able to tell anyway icon_lol.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 5
No new posts ICETOOL returns no records JCL & VSAM 1
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
Search our Forums:

Back to Top