Quantcast
Channel: IBM Mainframe Computers Forums
Viewing all articles
Browse latest Browse all 9405

DFSORT/ICETOOL :: RE: sort with previous record

$
0
0
Author: RahulG31
Subject: Reply to: sort with previous record
Posted: Thu Oct 06, 2016 9:52 pm (GMT 5.5)

My idea:
I would push position 7 of previous record and add some decimal value myself and then sort on the value including decimal. But then we'll have to take care of the character 'W'. I think it's just simpler to show what I did to achieve what you want:
Code:
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(7,1,CH,NE,C'W'),PUSH=(9:7,1)),
        IFTHEN=(WHEN=(7,1,CH,NE,C'W'),BUILD=(1:1,9,10:C'.1')),
        IFTHEN=(WHEN=(7,1,CH,EQ,C'W'),BUILD=(1:1,9,10:C'.2'))
 SORT FIELDS=(9,3,CH,A)
 OUTFIL BUILD=(1,7)

So, with input as this:
Code:
AAAAA
AAAAA 8
AAAAA 7
AAAAA 6
AAAAA W
AAAAA 0
AAAAA 1   

I get output as this:
Code:
AAAAA
AAAAA 0
AAAAA 1
AAAAA 6
AAAAA W
AAAAA 7
AAAAA 8


.


Viewing all articles
Browse latest Browse all 9405

Trending Articles