View previous topic :: View next topic
|
Author |
Message |
vinit_infy Warnings : 1 New User
Joined: 07 Apr 2005 Posts: 56
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
vinit_infy Warnings : 1 New User
Joined: 07 Apr 2005 Posts: 56
|
|
|
|
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 |
|
|
Bhargav_1058
New User
Joined: 13 Dec 2008 Posts: 53 Location: New York
|
|
|
|
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 |
|
|
vinit_infy Warnings : 1 New User
Joined: 07 Apr 2005 Posts: 56
|
|
|
|
Thanks Bhargav... |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
|