View previous topic :: View next topic
|
Author |
Message |
manitonline
New User
Joined: 17 Sep 2005 Posts: 5 Location: Noida
|
|
|
|
I need to do sorting on some selective rows only in a file. The case is something like this:
Code: |
Seq Name Code
1 A1 11
4 A1 344
3 A3 3
1 A3 434
2 A3 43
6 A3 343
7 A4 434
8 A4 45
8 A4 4
2 A6 8
|
In the above example, I need to sort only the rows (in Ascending order of Seq) where Name is A3. The other rows should remain in the order they r in the input file (No sorting on them).
Could you tell me how to create a sort card for the same.
Thanx
Mann |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
You gave a nice example of your input, how about providing an example of what you want the output to look like? |
|
Back to top |
|
|
manitonline
New User
Joined: 17 Sep 2005 Posts: 5 Location: Noida
|
|
|
|
The output should be:
Code: |
Seq Name Code
1 A1 11
4 A1 344
1 A3 434
2 A3 43
3 A3 3
6 A3 343
7 A4 434
8 A4 45
8 A4 4
2 A6 8
|
Here you'll see that only the rows where name is A3 have been sorted based on Seq. The other rows are not sorted and remain as it is. I hope this clarifies my requirement.
Thanks[/u] |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Have you looked at Frank's Smart DFSORT Tricks and the method of sorting records between a header and trailer? If you treat those records where Name is less that A3 as headers and greater than A3 as trailers, it should work..... |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Mann,
Here's a DFSORT job that will do what I think you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1 A1 11
4 A1 344
3 A3 3
1 A3 434
2 A3 43
6 A3 343
7 A4 434
8 A4 45
8 A4 4
2 A6 8
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'0')),
IFTHEN=(WHEN=(9,2,CH,EQ,C'A3'),OVERLAY=(81:1,1))
OPTION EQUALS
SORT FIELDS=(9,2,CH,A,81,1,CH,A)
OUTREC BUILD=(1,80)
/*
|
|
|
Back to top |
|
|
|