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

Help in sorting the file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vinit_infy
Warnings : 1

New User


Joined: 07 Apr 2005
Posts: 56

PostPosted: Tue Jun 02, 2009 1:46 pm
Reply with quote

I have a flat file having records like -

001hhGGGGGGGGGGGGGGGGGGGGGGGGGGG
001aa111111111111111111111111111
001bb222222222222222222222222222
001aasssssssssssssssssssssssssss
001ssEEEEEEEEEEEEEEEEEEEEEEEEEEE
001ddWWWWWWWWWWWWWWWWWWWWWWWWWWW
001aaTTTTTTTTTTTTTTTTTTTTTTTTTTT
001ttYYYYYYYYYYYYYYYYYYYYYYYYYYY

The requirement is to create a new file which will copy the above file but that file will having only one (first one) aa (4 TO 5 POSITION) record and exclude the rest of the aa record. So the output would be as


001hhGGGGGGGGGGGGGGGGGGGGGGGGGGG
001aa111111111111111111111111111
001bb222222222222222222222222222
001ssEEEEEEEEEEEEEEEEEEEEEEEEEEE
001ddWWWWWWWWWWWWWWWWWWWWWWWWWWW
001ttYYYYYYYYYYYYYYYYYYYYYYYYYYY

Could some one please let me know the optimum way to achieve this?
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Jun 02, 2009 2:40 pm
Reply with quote

does sequence of records in output matters?
if no then you can just use

Code:

//SYSIN    DD *         
 SORT FIELDS=(4,2,CH,A)
 SUM FIELDS=NONE       
/* 
Back to top
View user's profile Send private message
vinit_infy
Warnings : 1

New User


Joined: 07 Apr 2005
Posts: 56

PostPosted: Tue Jun 02, 2009 2:47 pm
Reply with quote

Thanks Sambhaji. I think i missed one more thing here.

each record having dates with it like

001hh20091020GGGGGGGGGGGGGGGGGGGG
001aa200910201111111111111111111
001bb200910202222222222222222222
001aa20091019ssssssssssssssssss
001ss20091020EEEEEEEEEEEEEEEEEEE
001dd20091020WWWWWWWWWWWWWWWWWWWWWW
001aa20091020TTTTTTTTTTTTTTTTTTT
001tt20091020YYYYYYYYYYYYYYYYYY

I want only that aa record which having latest date with it. That means output should be

001hh20091020GGGGGGGGGGGGGGGGGGGG
001bb200910202222222222222222222
001ss20091020EEEEEEEEEEEEEEEEEEE
001dd20091020WWWWWWWWWWWWWWWWWWWWWW
001aa20091021TTTTTTTTTTTTTTTTTTT
001tt20091020YYYYYYYYYYYYYYYYYY

Please advise if possible what should be good approach to do this.
Back to top
View user's profile Send private message
Bhargav_1058

New User


Joined: 13 Dec 2008
Posts: 53
Location: New York

PostPosted: Tue Jun 02, 2009 3:33 pm
Reply with quote

If sequence of records in output doesn't matters

then use below...

STEP1:
SORT FIELDS=(6,8,ZD,D) - to get the latest date record as first record.

STEP2:
SORT FIELDS=(4,2,CH,A)
SUM FIELDS=NONE - will gives you the output in the required format.
Back to top
View user's profile Send private message
vinit_infy
Warnings : 1

New User


Joined: 07 Apr 2005
Posts: 56

PostPosted: Tue Jun 02, 2009 3:49 pm
Reply with quote

Thanks Bhargav...
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Jun 02, 2009 8:13 pm
Reply with quote

vinit_infy,

If you're not bothered about the order of output records, the below single-pass SyncSort job would do the same.
Code:
//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DSN= Input file    -----> FB/LRECL=80
//SORTOUT  DD DSN= Output File   -----> FB/LRECL=80
//SYSIN    DD *                                                 
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),           
        IFTHEN=(WHEN=(4,2,CH,EQ,C'aa'),OVERLAY=(81:C'99999999'))
  SORT FIELDS=(81,8,ZD,A,6,8,ZD,A)                             
  OUTFIL REMOVECC,NODETAIL,SECTIONS=(4,2,TRAILER3=(1,80))       
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top