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
 

 

To Sort the latest record

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

New User


Joined: 27 Feb 2009
Posts: 12
Location: Bangalore

PostPosted: Wed Jul 08, 2009 10:50 pm    Post subject: To Sort the latest record
Reply with quote

Hi,

I have, say 3 variable length recod files of max legth 32756. I want to merge the data in all the 3 files eliminating the dulicates but the latest record should be in output file for e.g the input files are

File1
AA1
BB1
FF1
XX1

File2
CC2
AA2
DD2
FF2

File3
MM3
BB3
AA3
DD3

The output should be

AA3
BB3
CC2
DD3
FF2
MM3
XX1
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 Jul 08, 2009 11:30 pm    Post subject:
Reply with quote

Hello,

What defines "latest"?

What are the positions of the "keys"?
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 Jul 08, 2009 11:31 pm    Post subject:
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for. I used the positions shown in your example. Adjust appropriately for other positions, but remember that for a VB file, the RDW is in positions 1-4 so the first data byte starts at position 5.

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//CON DD DSN=...  input file1 (VB/32756)
//    DD DSN=...  input file2 (VB/32756)
//    DD DSN=...  input file3 (VB/32756)
//OUT DD DSN=...  output file (VB/32756)
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(5,2,CH) FIRST USING(CTL1)
/*
//CTL1CNTL DD *
  SORT FIELDS=(5,2,CH,A,7,1,ZD,D)
/*
Back to top
View user's profile Send private message
krishnakanagal

New User


Joined: 27 Feb 2009
Posts: 12
Location: Bangalore

PostPosted: Wed Jul 08, 2009 11:40 pm    Post subject: Hi Frank,
Reply with quote

I am sorry the Key Fields are first two bytes i have added the Suffix to identify from which file the record is coming.
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 Jul 08, 2009 11:43 pm    Post subject:
Reply with quote

From your example, I assumed that the "latest record" was indicated by the highest number in the suffix and that's what I gave you the job for. If that's not what you're trying to do, then please show a better example of input and expected output and explain the "rules" for getting from input to output (e.g. how do you determine the "latest record").
Back to top
View user's profile Send private message
krishnakanagal

New User


Joined: 27 Feb 2009
Posts: 12
Location: Bangalore

PostPosted: Thu Jul 09, 2009 12:15 am    Post subject:
Reply with quote

In the Example, File3 is having the latest records and file1 is having oldest. There is some data after the first two bytes. that data being different for a given key. So the in put files are

File1
AAxxxxxxxxxxxxx
BBhhhhhhhhhhhhh
FFnnnnnnnnnnnnnn
XXkkkkkkkkkkkkk

File2
CCrrrrrrrrrrrrrrrrr
AAcccccccccccccc
DDsssssssssssss
FFiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

File3
MMqqqqqqqqqqqqq
BBaaaaaaaaaaaaaaaaa
AAzzzzzzzzzzzzzzzzz
DDwww

The 3rd file is latest file.

The output file should be

AAzzzzzzzzzzzzzzzzz
BBaaaaaaaaaaaaaaaaa
CCrrrrrrrrrrrrrrrrr
DDwww
FFiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
MMqqqqqqqqqqqqq
XXkkkkkkkkkkkkk
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: Thu Jul 09, 2009 12:46 am    Post subject:
Reply with quote

Oh, that's even easier. Just concatenate the files in reverse order - file3, file2, file1 and use this DFSORT/ICETOOL job:

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//CON DD DSN=...  input file3 (VB/32756)
//    DD DSN=...  input file2 (VB/32756)
//    DD DSN=...  input file1 (VB/32756)
//OUT DD DSN=...  output file (VB/32756)
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(5,2,CH) FIRST
/*

Back to top
View user's profile Send private message
krishnakanagal

New User


Joined: 27 Feb 2009
Posts: 12
Location: Bangalore

PostPosted: Thu Jul 09, 2009 1:13 am    Post subject:
Reply with quote

Frank,

Any idea Wat will happen if i do a normal sort

Code:

//ABCDEFGH EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN    DD DSN=FILE3
//               DD DSN=FILE2
//               DD DSN=FILE1
//SORTOUT DD DSN=FILE4
//SYSIN      DD *
  SORT FIELDS=COPY
  SUM FIELDS=NONE
/*
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: Thu Jul 09, 2009 1:50 am    Post subject:
Reply with quote

SORT FIELDS=COPY would do a copy, not a sort and you'd get all of the records since SUM is ignored for COPY.

You can do it with DFSORT instead of ICETOOL like this:

Code:

//ABCDEFGH EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN    DD DSN=FILE3
//               DD DSN=FILE2
//               DD DSN=FILE1
//SORTOUT DD DSN=FILE4
//SYSIN      DD *
  OPTION EQUALS
  SORT FIELDS=(5,2,CH,A)
  SUM FIELDS=NONE
/*

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 Record Not found in AlX but record re... mukun264 COBOL Programming 7 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 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 SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm


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