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
 

 

question on sorting of records.

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

Active User


Joined: 11 Nov 2008
Posts: 143
Location: India

PostPosted: Fri Jul 30, 2010 7:12 pm    Post subject: question on sorting of records.
Reply with quote

I have a vsam file with the below record layout :

Code:
JH       2006                          40X
JL ----------SOME DATA1------------
JL ----------SOME DATA2------------
JL ----------SOME DATA3------------
JH      2009                           40X
JL ----------SOME DATA4------------
JL ----------SOME DATA5------------
JL ----------SOME DATA6------------
JH       2004                          40X
JL ----------SOME DATA7------------
JL ----------SOME DATA8------------
JL ----------SOME DATA9------------
JH       2009                          40X
JL ----------SOME DATA10------------
JL ----------SOME DATA11------------
JL ----------SOME DATA12------------


JH and JL are in position 1->2 (Length 2 )

DATE is in position 9-12 ( Lenght 4 )

String 40X is at 100->102 position ( Lenght 2)

Condition => if date at position 9-12 ( Lenght 4 ) equals 2009 then select the JH record with the 2009 date and all the JL records following the selected JH records.

For example in above case below output is desired :

Code:
JH      2009                           40X
JL ----------SOME DATA4------------
JL ----------SOME DATA5------------
JL ----------SOME DATA6------------
JH       2009                          40X
JL ----------SOME DATA10------------
JL ----------SOME DATA11------------
JL ----------SOME DATA12------------


Thanks,
Back to top
View user's profile Send private message

sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Fri Jul 30, 2010 8:52 pm    Post subject:
Reply with quote

Mukesh Pandey,

You haven't provided enough information so I am assuming 120 byte FB input file.

Code:
//SORT01   EXEC PGM=SORT                                               
//SORTIN   DD  *                                                       
JH      2006 40X                                                       
JL ----------SOME DATA1------------                                     
JL ----------SOME DATA2------------                                     
JL ----------SOME DATA3------------                                     
JH      2009 40X                                                       
JL ----------SOME DATA4------------                                     
JL ----------SOME DATA5------------                                     
JL ----------SOME DATA6------------                                     
JH      2004 40X                                                       
JL ----------SOME DATA7------------                                     
JL ----------SOME DATA8------------                                     
JL ----------SOME DATA9------------                                     
JH      2009 40X                                                       
JL ----------SOME DATA10------------                                   
JL ----------SOME DATA11------------                                   
JL ----------SOME DATA12------------                                   
/*                                                                     
//SORTOUT  DD  SYSOUT=*                                                 
//SYSIN DD *                                                           
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(124:X)),                             
       IFTHEN=(WHEN=GROUP,BEGIN=(01,02,CH,EQ,C'JH'),PUSH=(121:9,4))     
 SORT FIELDS=COPY                                                       
 OUTFIL INCLUDE=(121,4,CH,EQ,C'2009'),BUILD=(1,120)                     
/*                                                                     
//SYSOUT DD SYSOUT=*                                                   
//*                                                                     



If your RECFM/LRECL is different then let us know with sample input data.

Thanks,
Back to top
View user's profile Send private message
Mukesh Pandey

Active User


Joined: 11 Nov 2008
Posts: 143
Location: India

PostPosted: Fri Jul 30, 2010 9:00 pm    Post subject:
Reply with quote

Let me test your code.


Thanks,
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: Fri Jul 30, 2010 9:18 pm    Post subject:
Reply with quote

Mukesh,

Here's a DFSORT job that will do what you asked for. Since you said you have '40X' in in 100-102, I assumed your input file has RECFM=FB and LRECL=102, but the job can be changed appropriately for other attributes.

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (VSAM)
//SORTOUT DD DSN=...  output file (FB/102)
//SYSIN DD *
  OPTION COPY
  RECORD TYPE=F
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'JH'),
    PUSH=(103:9,4))
  OUTFIL INCLUDE=(103,4,CH,EQ,C'2009'),BUILD=(1,102)
/*
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Fri Jul 30, 2010 9:44 pm    Post subject:
Reply with quote

Well, I am not the original poster but learnt a lesson today that PUSH doesn't require increasing length. I didn't notice that earlier. Don't know why I added first WHEN=INIT.

Thanks Frank.
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: Fri Jul 30, 2010 9:51 pm    Post subject:
Reply with quote

Yes, PUSH (like OVERLAY) will increase the length when appropriate.

Also, since the input is VSAM, we should use RECORD TYPE=F to ensure that the records are processed as fixed-length. I just added that to my previous post (meant to, but forgot).
Back to top
View user's profile Send private message
Mukesh Pandey

Active User


Joined: 11 Nov 2008
Posts: 143
Location: India

PostPosted: Sun Aug 01, 2010 8:03 pm    Post subject:
Reply with quote

Hi Frank,

Thanks for your reply.

The select condition needs to be updated :

Condition => if date at position 9-12 ( Lenght 4 ) equals 2009 and the string at pos 100->103 equals 40X, then select the JH record with the 2009 date and all the JL records following the selected JH records.

The lrecl of the vsam file is 188.

Can you please suggest.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Aug 02, 2010 10:30 pm    Post subject:
Reply with quote

Mukesh Pandey,

Use the following DFSORT control cards

Code:

//SYSIN DD *
  OPTION COPY
  RECORD TYPE=F
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'JH'),
    PUSH=(189:9,4,100,3))
  OUTFIL BUILD=(1,188),INCLUDE=(189,7,CH,EQ,C'200940X')   
//*
Back to top
View user's profile Send private message
Mukesh Pandey

Active User


Joined: 11 Nov 2008
Posts: 143
Location: India

PostPosted: Tue Aug 03, 2010 1:50 pm    Post subject:
Reply with quote

Thanks Skolusu. Concept is clear to me and the requirement is met.
Back to top
View user's profile Send private message
Mukesh Pandey

Active User


Joined: 11 Nov 2008
Posts: 143
Location: India

PostPosted: Tue Oct 19, 2010 1:26 pm    Post subject: New question on sort
Reply with quote

Hi i have a new requirement based on th eabove scenarion...

Code:
I/p file

JH1806                                                                                ##           
JL  DATA1(Pos(3-17))    DATA2(Pos(51))   DATA3(POS(75-79))
JL                 "                             "                              "
.
.
JL
JH1806                                                                                #*



Need to sort the JL records inorder to eliminate duplicates on the field DATA1, DATA2 and DATA3

Means if value of DATA1,DATA2 and DATA3 is same for more than one rows then the duplicate rows shud be eliminated.


Thanks,
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: Tue Oct 19, 2010 11:18 pm    Post subject:
Reply with quote

You need to do a better job of explaining your new requirement. It's not clear what you want to do exactly. Give a better example of input and expected output, explain the rules, give RECFM and LRECL, position, length and format of fields, etc.
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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Efficient sorting chandracdac DFSORT/ICETOOL 5 Sat Oct 22, 2016 3:23 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


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