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 

Sort Problem

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


Joined: 29 Jan 2004
Posts: 62
Topics: 19

PostPosted: Fri May 21, 2004 3:46 am    Post subject: Sort Problem Reply with quote

Hi,

I need to use only syncsort to acheive the solution for the given below problem in a single step.

Problem: My input file is of length 3123. I need to create 2 output file.

Requirement: Input file have 16 digit Policy number, 10 digit date & Flag(which can have 'F' or 'A') and the condition is if the duplicate Policy comes with different date then I have to keep the Oldest date record.

Output 1) Only one field. i.e Unique Policy Number (Policy only which comes with Flag 'F")

Output 2) all records...Sorted on the basis of policy and date fields... Without any duplicate...(i.e. it might happen that more than 1 record comes with same policy with everything same except the date , then in that case i have to keep the oldest date)

I tried out with following control card but its not giving the desire result:

INREC FIELDS=(1,80)
SORT FIELDS=(35,16,CH,A,63,10,CH,A,)
SUM FIELDS=NONE
OUTFIL FILES=01,INCLUDE=(80,1,CH,EQ,C'F'),OUTREC=(35,16)
OUTFIL FILES=02,INCLUDE=(80,1,CH,NE,C' '),OUTREC=(1,80)
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri May 21, 2004 5:15 am    Post subject: Reply with quote

Rahul,

Can you post a sample Input and desired output.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rahull
Beginner


Joined: 29 Jan 2004
Posts: 62
Topics: 19

PostPosted: Fri May 21, 2004 5:26 am    Post subject: Reply with quote

Hi,

First of all, there is a correction, the input file is of 3123 and I mentioned 80 in the control card.

Sample Input:
+----4----+----5----+----6----+----7----+----8 ----124----
5106A 777802 A451010001222003-01-10 F
5106A 777802 A451010001222003-01-11 F
5106A 888786 A451010001182003-01-10 A
5106A 888786 A451010001182003-01-19 A

Output 1)
----+----1----+-
5106A 777802

Output 2)
+----4----+----5----+----6----+----7----+----8 ----124----
5106A 777802 A451010001222003-01-10 F
5106A 888786 A451010001182003-01-10 A
Back to top
View user's profile Send private message
Rahull
Beginner


Joined: 29 Jan 2004
Posts: 62
Topics: 19

PostPosted: Fri May 21, 2004 5:33 am    Post subject: Reply with quote

sorry there was an alignment problem....
Hi,

First of all, there is a correction, the input file is of 3123 and I mentioned 80 in the control card.

Sample Input:
Column (starting from 35)
Code:

+----4----+----5----+----6----+----7----+----8.........---124----
5106A 777802 A451010001222003-01-10................    F
5106A 777802 A451010001222003-01-11................    F
5106A 888786 A451010001182003-01-10................    A
5106A 888786 A451010001182003-01-19................    A

Output 1:
Code:

----+----1----+-
5106A 777802

Output 2:
Code:

+----4----+----5----+----6----+----7----+----8-----.....--124----
5106A 777802 A451010001222003-01-10................     F
5106A 888786 A451010001182003-01-10................     A
Back to top
View user's profile Send private message
sasubashri
Beginner


Joined: 20 May 2003
Posts: 15
Topics: 7

PostPosted: Fri May 21, 2004 5:40 am    Post subject: Reply with quote

Rahul,
Hope this helps.

Temp1 will have the output1 and temp2 the output2 as shown in your post.
Code:

//STEP1 EXEC PGM=SYNCTOOL                                   
//INDD DD DSN=YOURID.INPUT,DISP=SHR                         

//TEMP0 DD DSN=YOURID.TEMP0,                               
//      DISP=(NEW,CATLG,DELETE),SPACE=(TRK,(45,10),RLSE)     

//TEMP1  DD DSN=YOURID.TEMP1,                               
//      DISP=(NEW,CATLG,DELETE),SPACE=(TRK,(45,10),RLSE)     
//TEMP2  DD DSN=YOURID.TEMP2,                               
//      DISP=(NEW,CATLG,DELETE),SPACE=(TRK,(45,10),RLSE)     
//OUT1CNTL DD *
  SORT FIELDS=(35,16,CH,A,63,10,CH,A,) ,FORMAT=CH   
/*
//OUT2CNTL DD *
 SORT FIELDS=(35,16,CH,A,81,1,CH,A)         
 INCLUDE COND=(81,1,CH,EQ,C'F')           
 SUM FIELDS=NONE                         
 OUTFIL FNAMES=TEMP1,OUTREC=(1:35,16)
/*
//OUT3CNTL DD *
 SORT FIELDS=(35,16,CH,A,1,34,CH,A,51,11,CH,A,73,3050,CH,A)
 SUM FIELDS=NONE                   
 OUTFIL FNAMES=TEMP2               
//SYSOUT DD SYSOUT=*                                         
//TOOLMSG DD SYSOUT=*                                       
//SSMSG DD SYSOUT=*                                         

//TOOLIN DD *                                               
  SORT FROM(INDD) TO(TEMP0) USING(OUT1)                     
  SORT FROM(TEMP0) TO(TEMP1) USING(OUT2)                     
  SORT FROM(TEMP0)  TO(TEMP2) USING(OUT3)                   
/*                                                           


Kolusu,
Is there a better way of solving this problem ?

Thanks,
Subashri.
_________________
Thanks,
Subashri.
Back to top
View user's profile Send private message
sasubashri
Beginner


Joined: 20 May 2003
Posts: 15
Topics: 7

PostPosted: Fri May 21, 2004 5:44 am    Post subject: Reply with quote

Rahull,
I assumed the position of the flag to be on 81. Please change that to 122.

Thanks,
Subashri.
_________________
Thanks,
Subashri.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri May 21, 2004 5:51 am    Post subject: Reply with quote

Rahul,

If I understand correctly your Policy number starts from pos 35 for 16 bytes and your date is in position 63 for 10 bytes and your flag indicator is in pos 124? If this assumption correct, then the following job will give you the desired results.
Code:

//STEP0100 EXEC PGM=SYNCTOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN       DD DSN=YOUR INPUT FILE,
//            DISP=SHR
//OUT1     DD DSN=YOUR UNIQUE F POLICY NUMBER FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//OUT2     DD DSN=YOUR ALLOTHER POLICY NUMBER FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//TOOLIN   DD *
  SELECT FROM(IN) TO(OUT1) ON(35,16,CH) ON(124,1,CH) FIRST
  SELECT FROM(IN) TO(OUT1) ON(35,16,CH) ON(63,10,CH) FIRST
/*


Subhasri : The Job you posted is too clumsy. I don't know as to why you used the following sort fields on OUT3CNTL DD statement

Code:

SORT FIELDS=(35,16,CH,A,1,34,CH,A,51,11,CH,A,73,3050,CH,A)


You don't need sysout and ssmsg dd statements

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rahull
Beginner


Joined: 29 Jan 2004
Posts: 62
Topics: 19

PostPosted: Fri May 21, 2004 5:53 am    Post subject: Reply with quote

My Client doesn't allowing me to usee SYNCTOOL ...

We can use only SORT or SYNCSORT.
Back to top
View user's profile Send private message
Rahull
Beginner


Joined: 29 Jan 2004
Posts: 62
Topics: 19

PostPosted: Fri May 21, 2004 5:57 am    Post subject: Reply with quote

Kolusu Is it possible using SYNCSORT ????
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri May 21, 2004 6:00 am    Post subject: Reply with quote

Rahul,

Synctool is a part of syncsort but it is an unsupported feature. You can split the job into 2 steps as follows.

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=YOUR INPUT FILE,
//            DISP=SHR
//SORTOUT  DD DSN=YOUR UNIQUE F POLICY NUMBER FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *
 OPTION EQUALS
  INCLUDE COND=(124,1,CH,EQ,C'F')
  SORT FIELDS=(35,16,CH,A)    $ POLICY NUMBER
  SUM FIELDS=NONE
  OUTREC FIELDS=(35,16)
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=YOUR INPUT FILE,
//            DISP=SHR
//SORTOUT  DD DSN=YOUR ALLOTHER POLICY NUMBER FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *
 OPTION EQUALS
  OMIT COND=(124,1,CH,EQ,C' ')
  SORT FIELDS=(35,16,CH,A,    $ POLICY NUMBER
               63,10,CH,A)    $ POLICY DATE
  SUM FIELDS=NONE
//*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rahull
Beginner


Joined: 29 Jan 2004
Posts: 62
Topics: 19

PostPosted: Fri May 21, 2004 6:13 am    Post subject: Reply with quote

Thanks but I knew doing that in 2 steps. The challenge before me to do in one step..
See below is the new control card I am using..

INREC FIELDS=(1,3123)
SORT FIELDS=(35,16,CH,A,124,1,CH,A)
SUM FIELDS=NONE
OUTFIL FILES=01,INCLUDE=(124,1,CH,EQ,C'F'),OUTREC=(35,16)
OUTFIL FILES=02,INCLUDE=(124,1,CH,NE,C' '),OUTREC=(1,3123)

First output is as per my requirement.
But second output keep the policy which comes first in order. I want the policy with oldest date. How do i use the data feild in above card.
Any suggestion??
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri May 21, 2004 6:23 am    Post subject: Reply with quote

Rahul,

Try this

Code:

 OPTION EQUALS
 INREC FIELDS=(1,3123)
 SORT FIELDS=(35,16,CH,A,63,10,CH,A,124,1,CH,D)
 SUM FIELDS=NONE
 OUTFIL FILES=01,INCLUDE=(124,1,CH,EQ,C'F'),OUTREC=(35,16)
 OUTFIL FILES=02,INCLUDE=(124,1,CH,NE,C' '),OUTREC=(1,3123)


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rahull
Beginner


Joined: 29 Jan 2004
Posts: 62
Topics: 19

PostPosted: Fri May 21, 2004 6:50 am    Post subject: Reply with quote

Hi,

I tried with the option that u mentioned.

Sorry but could not get unique result for both the output file.

I am still getting the same policy record 2 times with everything same except the date for output 2.

and for output 1 ..same policy number 2 times ( Becuase in input file everything is same except the date..)
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri May 21, 2004 9:03 am    Post subject: Reply with quote

Rahul,

I can't think of a way to achieve it in a single step. sorry

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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