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 

Need help in sorting

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


Joined: 09 Nov 2006
Posts: 35
Topics: 12

PostPosted: Mon Oct 15, 2007 6:39 am    Post subject: Need help in sorting Reply with quote

This is the copybook layout of my input file:
Code:

05  SSN                           PIC X(09).
05  HICN                          PIC X(12).
05  FIRST-NAME                    PIC X(30).
05  MID-INT                       PIC X(1).
05  LAST-NAME                     PIC X(40).
05  BIRTH-DT                      PIC 9(8).
05  GNDR-CD                       PIC X(1).
05  COV-EFF-DT                    PIC 9(8).
05  COV-CANC-DT                   PIC 9(8).
05  UBOI                          PIC X(20).
05  REL-CD                        PIC X(2).
05  TRANS-TYPE                    PIC X(3).
05  DET-IND                       PIC X(1).
05  REASON                        PIC X(2).
05  SBSDY-EFF-DT                  PIC 9(8).
05  SBSDY-CANC-DT                 PIC 9(8).
05  APPL-ID                       PIC X(10).
05  NASCO-GRP-ID                  PIC X(9).
05  NASCO-SUBGRP-ID               PIC X(4).
05  NASCO-PKG-NBR                 PIC X(3).
05  NASCO-SUB-ID                  PIC 9(13).
05  NASCO-DEP-ID                  PIC 9(2).
05  SRC-SYS-KEY                   PIC 9(3).
05  FILLER                        PIC X(15).
05  NOTIF-REAS                    PIC X(4).
05  FILLER                        PIC X(35).
05  Timestamp                     PIC X(14).
05  FILLER                        PIC X(127).


So i need to sort the INPUT file based on the key(NASCO-SUB-ID,NASCO-DEP-ID,SRC-SYS-KEY) to get the latest record with respect to the Timestamp.

The key which i have mentioned above forms the unique key for that input file. so i need to retrieve the latest record containing the highest timestamp from the input file for each unique key.

In the Input file, some of the records contains 'blanks' for the columns NASCO-SUB-ID,NASCO-DEP-ID respectively.

when i tried to sort using JCL, the records conatining blanks in the Key field are getting eliminated.

All the records contain SRC-SYS-KEY column in the input file.

please suggest me how to proceed.
Back to top
View user's profile Send private message
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Mon Oct 15, 2007 7:57 am    Post subject: Reply with quote

waves,

Quote:

when i tried to sort using JCL, the records conatining blanks in the Key field are getting eliminated.


Provide us the JCL which u had tried so that we can help u out where u were missing.

Quote:

All the records contain SRC-SYS-KEY column in the input file.


Also give a subset of the output record so that we can have a look at it.
_________________
Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
Back to top
View user's profile Send private message
waves
Beginner


Joined: 09 Nov 2006
Posts: 35
Topics: 12

PostPosted: Mon Oct 15, 2007 9:23 am    Post subject: Reply with quote

//STEP110 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTIN DD DSN=TEST.RDSRSP.HISTORY.NASCO.FILE.OCT07,
// DISP=(OLD,KEEP)
//SORTOUT DD DSN=TEST.HISTORY.NASCO.FILE.OCT15.SORT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,MGMTCLAS=WORK6M,
// LIKE=TEST.RDSRSP.HISTORY.NASCO.FILE.OCT07
//SYSIN DD *
SORT FIELDS=(188,13,CH,A,201,2,CH,A,203,3,CH,A,260,14,CH,D)
//*
//STEP120 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTIN DD DSN=TEST.HISTORY.NASCO.FILE.OCT15.SORT,
// DISP=(OLD,KEEP)
//SORTOUT DD DSN=TEST.HISTORY.NASCO.FILE.OCT15.SORT.NEW,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,MGMTCLAS=WORK6M,
// LIKE=TEST.HISTORY.NASCO.FILE.OCT15.SORT
//SYSIN DD *
SORT FIELDS=(188,13,CH,A,201,2,CH,A,203,3,CH,A)
OPTION EQUALS
SUM FIELDS=NONE
//*


this was the jcl i used.

the lrecl is 400.

i dont know to give the sample output here...
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Mon Oct 15, 2007 1:09 pm    Post subject: Reply with quote

This does not appear to be a JCL problem but a SORT problem so it should be posted in the Utilities section where SORT threads are. However, that said, there are a couple pf points:
    as your keys, excluding Timestamp, are contiguous you can code one condition instead of 3

    these same 3 keys are numeric (PIC 9) but you are sorting as character (CH) instead of numeric (ZD - zoned decimal)

    SUM FIELDS=NONE will drop duplicate key records but I believe all the keys have to be duplicate so are you 100% sure that SRC-SYS-KEY is ALWAYS non-blank?

_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Mon Oct 15, 2007 1:37 pm    Post subject: Reply with quote

Quote:
when i tried to sort using JCL, the records conatining blanks in the Key field are getting eliminated.


waves,

It's not clear what you think the problem is.

Since you're using SUM FIELDS=NONE, all but one of the records containing blanks in the key field would be eliminated. That's what SUM FIELDS=NONE does.

What is it exactly you want for the output?

Sample input and output would be something like this:

Input

Code:

key...............timestamp.....
CCCCCCCCCCCCCDDEEE11111111111111
CCCCCCCCCCCCCDDEEE22222222222222
AAAAAAAAAAAAABBCCC11111111111111
AAAAAAAAAAAAABBCCC22222222222222
AAAAAAAAAAAAABBCCC33333333333333
               FFF00000000000000
               FFF22222222222222
               FFF44444444444444
BBBBBBBBBBBBBCCDDD33333333333333


Expected output

Code:

key...............timestamp.....
               FFF44444444444444 
AAAAAAAAAAAAABBCCC33333333333333 
BBBBBBBBBBBBBCCDDD33333333333333 
CCCCCCCCCCCCCDDEEE22222222222222 

_________________
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
waves
Beginner


Joined: 09 Nov 2006
Posts: 35
Topics: 12

PostPosted: Tue Oct 16, 2007 8:21 am    Post subject: Reply with quote

so are you 100% sure that SRC-SYS-KEY is ALWAYS non-blank?[/list][/quote]

i'm very sure that all the SRC-SYS-KEY are always non-blank.

thank you very much for the valuable suggestion.

please correct me where i went wrong.
Back to top
View user's profile Send private message
waves
Beginner


Joined: 09 Nov 2006
Posts: 35
Topics: 12

PostPosted: Tue Oct 16, 2007 8:32 am    Post subject: Reply with quote

Frank,

Absolutely you are right!!!. i want the output in the same manner wat you have mentioned.

please help me!!!
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Tue Oct 16, 2007 10:03 am    Post subject: Reply with quote

Well, I tried YOUR job with DFSORT using that input and got that output, so it's difficult for me to tell you where you went wrong.

Here's a one-pass approach with DFSORT/ICETOOL you can try that gives the same results:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file
//OUT DD DSN=...  output file
//TOOLIN   DD    *
SELECT FROM(IN) TO(OUT) ON(188,13,CH) ON(201,2,CH) ON(203,3,CH) -
  FIRST USING(CTL1)
/*
//CTL1CNTL DD *
  SORT FIELDS=(188,13,CH,A,201,2,CH,A,203,3,CH,A,260,14,CH,D)
/*

_________________
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


Last edited by Frank Yaeger on Tue Oct 16, 2007 11:26 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
waves
Beginner


Joined: 09 Nov 2006
Posts: 35
Topics: 12

PostPosted: Tue Oct 16, 2007 10:59 am    Post subject: Reply with quote

Frank,

thanks a ton for the quick reply.

i'm using the SYNCSORT Product.

please help me how to get the same output using SYNCSORT.

thanks in advance.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Tue Oct 16, 2007 11:25 am    Post subject: Reply with quote

Quote:
please help me how to get the same output using SYNCSORT.


I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
_________________
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
waves
Beginner


Joined: 09 Nov 2006
Posts: 35
Topics: 12

PostPosted: Tue Oct 16, 2007 11:59 pm    Post subject: Reply with quote

can anybody help me out to get the output using SYNCSORT.

thanks in advance!!
Back to top
View user's profile Send private message
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