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
 

 

Processing last 200 records
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Processing last 200 records
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    Post subject: Reply to: Processing last 200 records
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    Post subject: Processing last 200 records
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    Post subject: Reply to: Processing last 200 records
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
http://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    Post subject:
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    Post subject: Processing last 200 records
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    Post subject: Reply to: Processing last 200 records
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    Post subject: Processing last 200 records
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    Post subject:
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

Senior Member


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

PostPosted: Wed May 26, 2010 4:38 pm    Post subject: Re: Processing last 200 records
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

Site Director


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

PostPosted: Wed May 26, 2010 8:48 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Wed May 26, 2010 11:28 pm    Post subject: Reply to: Processing last 200 records
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    Post subject:
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

Moderator Team Head


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

PostPosted: Thu May 27, 2010 12:13 am    Post subject: Reply to: Processing last 200 records
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: 7904
Location: Bellevue, IA

PostPosted: Thu May 27, 2010 12:20 am    Post subject:
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

Site Director


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

PostPosted: Thu May 27, 2010 12:25 am    Post subject:
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    Post subject:
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

Senior Member


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

PostPosted: Thu May 27, 2010 3:32 pm    Post subject: Reply to: Processing last 200 records
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Thu May 27, 2010 3:45 pm    Post subject:
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    Post subject:
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Run stats processing on zIIP Engine Virendra Shambharkar DB2 9 Fri Oct 14, 2016 10:24 am


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