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

To Sort the latest record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Wed Jul 08, 2009 11:30 pm
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 Developer


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

PostPosted: Wed Jul 08, 2009 11:31 pm
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
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 Developer


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

PostPosted: Wed Jul 08, 2009 11:43 pm
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
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 Developer


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

PostPosted: Thu Jul 09, 2009 12:46 am
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
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 Developer


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

PostPosted: Thu Jul 09, 2009 1:50 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top