MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Extracting last record

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
vijayakumar
Beginner


Joined: 28 Jul 2006
Posts: 17
Topics: 9

PostPosted: Wed Nov 07, 2007 7:08 am    Post subject: Extracting last record Reply with quote

Hi,
I need to extract the last four records from the input file based on
pol number, latest date(yyyymmdd).
Is there any icetool or sort command to do this.
Could you please help me on this problem

input file

[code:1:3a2d666219]
num
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Nov 07, 2007 11:02 am    Post subject: Reply with quote

You only show one policy number (123). Are there actual multiple policy numbers?
You show the same date for the "last" four records - is that always the case?
Please show a better example of input and output that answers these questions.
Please use code tags around your examples.

What is the RECFM and LRECL of the input file?

What is the starting position, length and format of the four fields?
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vijayakumar
Beginner


Joined: 28 Jul 2006
Posts: 17
Topics: 9

PostPosted: Wed Nov 07, 2007 11:31 am    Post subject: Reply with quote

Hi,
In the file there will be many policy numbers. For each polisy number all the latest
date records should be written to output file.
RECFM=FB, LRECL=25

Polisy number X(9)
Tran Date X(10)
Indicator X(1)
Code X(5)

Input file

Polisy num Tran date Indicator Code
C16956910 19980630 spaces CTCRZM
C16956910 20030228 'S' CTC001
C16956910 20030228 'S' CTC002
C16956910 20030228 'S' CTC003
C16956910 20030228 'S' CTC004

C16956942 19980531 spaces CTCCNC
C16956942 19981027 'S' CTC001
C16956942 19981027 'S' CTC002
C16956942 19981027 'S' CTC003
C16956942 19981027 'S' CTC004

C16956960 19980531 spaces CTCCNC
C16956960 19980608 spaces CTC001
C16956960 19980608 spaces CTC002
C16956960 19980608 spaces CTC003
C16956960 19980608 spaces CTC004

C16957170 19980529 spaces CTC001
C16957170 19980529 spaces CTC002
C16957170 19980529 spaces CTC003
C16957170 19980529 spaces CTC004

C16956961 19980529 spaces CTC001
C16956961 19980529 spaces CTC002
C16956961 19980529 spaces CTC003
C16956961 19980529 spaces CTC004
C16956961 19980631 'S' CTCCNC


Output file:

Polisy num Tran date Indicator Code
C16956910 20030228 'S' CTC001
C16956910 20030228 'S' CTC002
C16956910 20030228 'S' CTC003
C16956910 20030228 'S' CTC004

C16956942 19981027 'S' CTC001
C16956942 19981027 'S' CTC002
C16956942 19981027 'S' CTC003
C16956942 19981027 'S' CTC004

C16956960 19980608 spaces CTC001
C16956960 19980608 spaces CTC002
C16956960 19980608 spaces CTC003
C16956960 19980608 spaces CTC004

C16957170 19980529 spaces CTC001
C16957170 19980529 spaces CTC002
C16957170 19980529 spaces CTC003
C16957170 19980529 spaces CTC004

C16956961 19980631 'S' CTCCNC
Back to top
View user's profile Send private message Send e-mail
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Wed Nov 07, 2007 2:30 pm    Post subject: Reply with quote

vijayakumar,
Using BBCode makes your data more readable. See FAQ.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Nov 07, 2007 5:26 pm    Post subject: Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (FB/25)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file (FB/25)
//TOOLIN DD *
SELECT FROM(IN) TO(T1) ON(1,9,CH) FIRST USING(CTL1)
COPY FROM(IN) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(1,17,CH) -
  WITHALL WITH(1,26) USING(CTL3)
/*
//CTL1CNTL DD *
  SORT FIELDS=(1,9,CH,A,10,8,CH,D)
  OUTFIL FNAMES=T1,OVERLAY=(26:C'BB')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(26:C'VV')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(26,2,CH,EQ,C'VB'),
    BUILD=(1,25)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vijayakumar
Beginner


Joined: 28 Jul 2006
Posts: 17
Topics: 9

PostPosted: Thu Nov 08, 2007 9:36 am    Post subject: Reply with quote

Hi Frank,
Thanks for your help!!!!!!!
Logic worked fine....

Cheers
Vijay
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group