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
 

 

Help in sorting the file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Help in sorting the file
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
Reply with quote

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

Moderator


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

PostPosted: Tue Jun 02, 2009 8:13 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am


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