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

question on sorting of records.


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

PostPosted: Fri Jul 30, 2010 8:52 pm
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
Reply with quote

Let me test your code.


Thanks,
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: Fri Jul 30, 2010 9:18 pm
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: 577
Location: USA

PostPosted: Fri Jul 30, 2010 9:44 pm
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 Developer


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

PostPosted: Fri Jul 30, 2010 9:51 pm
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
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
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
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
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 Developer


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

PostPosted: Tue Oct 19, 2010 11:18 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top