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

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


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sen_1983us

New User


Joined: 21 May 2005
Posts: 21
Location: Hyderabad

PostPosted: Fri Feb 17, 2006 1:34 pm
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
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
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: 1448
Location: Chicago, IL

PostPosted: Fri Feb 17, 2006 6:39 pm
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 Developer


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

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

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

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Fri Feb 17, 2006 10:00 pm
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 Developer


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

PostPosted: Wed Sep 24, 2008 2:18 am
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:

Use [URL] BBCode for External Links
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top