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
 

 

how to read last 5 records from VSAM as well as Sequential

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
sen_1983us

New User


Joined: 21 May 2005
Posts: 18
Location: Hyderabad

PostPosted: Fri Feb 17, 2006 1:34 pm    Post subject: how to read last 5 records from VSAM as well as Sequential
Reply with quote

Hi all,

CAN any one tell me how to read lsat 5 recs from VSAm and also in Sequential files

Regards
Senthil
Back to top
View user's profile Send private message

rajesh_1183

Active User


Joined: 24 Nov 2005
Posts: 121
Location: Tadepalligudem

PostPosted: Fri Feb 17, 2006 5:35 pm    Post subject:
Reply with quote

I think,this helps......
Code:

//SORTIN DD DSN=INPUT FILE,DISP=SHR
//OUT1     DD DSN=OUTPPUT FILE,DISP=SHR
//SYSIN DD *
  OUTFIL FILES=OUT1,HEADER1=(1:"COUNT=',&COUNT),NODETAIL
/*

This will write the no.of records in OUTPPUT FILE at 7th position...
In the COBOL pgm define a record layout like...
Code:

01 out-rec.
   05 filler      pic x(6)
   05 count-value pic 9(5)--->I don't know exact pic clause

then in the prog write a loop like.....
Code:

MAIN-PARA.
OPEN THE REQ.FILES LIKE OUTPUT-FILE AND VSAM FILE
READ OUTPUT-FILE INTO OUT-REC
PERFORM PARA1 UNTIL I = COUNT-VALUE-5.
PERFORM PARA2 5 TIMES.
CLOSE ALL THE OPENED FILES
STOP RUN.
PARA1.
READ VSAM-FILE INTO WS-REC    --->SOME SAMPLE RECORD
ADD 1 TO I.
PARA2.                        --->PARAGRAPH READING LAST 5 RECORDS
READ VSAM-FILE INTO WS-REC


corrections welcomed...........

Thanks,
Rajesh[/code]
Back to top
View user's profile Send private message
rajesh_1183

Active User


Joined: 24 Nov 2005
Posts: 121
Location: Tadepalligudem

PostPosted: Fri Feb 17, 2006 5:37 pm    Post subject:
Reply with quote

I think we can also do the req. using REPRO...can any one suggest that...

Thanks,
Rajesh
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Fri Feb 17, 2006 6:39 pm    Post subject: Re: how to read last 5 records from VSAM as well as Sequenti
Reply with quote

http://ibmmainframes.com/viewtopic.php?t=5822

Regards,

Priyesh.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Feb 17, 2006 9:42 pm    Post subject:
Reply with quote

See the "Keep the last n records" Smart DFSORT Trick at:

www.ibm.com/systems/support/storage/software/sort/mvs/tricks/
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Feb 17, 2006 10:00 pm    Post subject:
Reply with quote

Rajesh wrote:

Code:

  OUTFIL FILES=OUT1,HEADER1=(1:"COUNT=',&COUNT),NODETAIL


This control statement is incorrect in several ways.

FILES=OUT1 is invalid. It should be FILES=OUT or FNAMES=OUT1.

"COUNT=' is invalid. It should be 'COUNT='.

&COUNT or COUNT cannot be used with HEADERx. It can only be used with TRAILERx.

The following is a valid control statement for creating a record with the count in positions 1-8:

Code:

  OUTFIL NODETAIL,REMOVECC,         
    TRAILER1=(COUNT=(M11,LENGTH=8)) 
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Sep 24, 2008 2:18 am    Post subject:
Reply with quote

Quote:
CAN any one tell me how to read lsat 5 recs from VSAm and also in Sequential files


You can now do this kind of thing quite easily using the new SUBSET operator of DFSORT's ICETOOL available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:

Code:
 
//S1  EXEC  PGM=ICETOOL                                           
//TOOLMSG   DD  SYSOUT=*                                           
//DFSMSG    DD  SYSOUT=*                                           
//IN DD DSN=...  input file                                       
//OUT DD DSN=...  output file         
//TOOLIN DD *                                                     
SUBSET FROM(IN) TO(OUT) KEEP INPUT LAST(5)
/*     


For complete details on the new SUBSET function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Updating a VSAM file with DISP=OLD sheersh JCL & VSAM 8 Tue Mar 14, 2017 6:14 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts VSAM RLS=NRI while doing IDCAMS sheersh JCL & VSAM 1 Tue Mar 07, 2017 1:55 pm


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