aravind83 ,
Step0100 will create a temp file with all the '2' records and put a value of '0' at pos 25
----+----1----+----2----+
123456ABCD 0
123789ABCF 0
step0200 will concatenate the temp file and original input and sort on the key fields and this how it looks like before OUTREC
----+----1----+----2----+
123456ABCD 0
123456ABCD 1
123456ABCD 1
123456ABCD 2
123456ACDE 1
123456ACDE 1
123456ACDE 1
123456ACDE 1
123456ACDE 1
123456ACDE 1
123789ABCF 0
123789ABCF 1
123789ABCF 1
123789ABCF 1
123789ABCF 1
123789ABCF 2
OUTREC IFTHEN=(WHEN=INIT,
BUILD=(1,4,25,1,X,SEQNUM,8,ZD,RESTART=(14,10),5)),
This will put the indicator in pos 5 and also a seqnum at pos 7 whenever the key(14,10) changes
0 00000001 123456ABCD 0
1 00000002 123456ABCD 1
1 00000003 123456ABCD 1
2 00000004 123456ABCD 2
1 00000001 123456ACDE 1
1 00000002 123456ACDE 1
1 00000003 123456ACDE 1
1 00000004 123456ACDE 1
1 00000005 123456ACDE 1
1 00000006 123456ACDE 1
0 00000001 123789ABCF 0
1 00000002 123789ABCF 1
1 00000003 123789ABCF 1
1 00000004 123789ABCF 1
1 00000005 123789ABCF 1
2 00000006 123789ABCF 2
IFTHEN=(WHEN=GROUP,BEGIN=(7,8,ZD,EQ,1),PUSH=(6:5,1))
OUTFIL INCLUDE=(5,2,SS,EQ,C'10,20'),BUILD=(1,4,15)
now if the seqnum we have at pos 7 we push down the value at 5 on pos 6 . now the contents will look like this
00 00000001 123456ABCD 0
10 00000002 123456ABCD 1
10 00000003 123456ABCD 1
20 00000004 123456ABCD 2
11 00000001 123456ACDE 1
11 00000002 123456ACDE 1
11 00000003 123456ACDE 1
11 00000004 123456ACDE 1
11 00000005 123456ACDE 1
11 00000006 123456ACDE 1
00 00000001 123789ABCF 0
10 00000002 123789ABCF 1
10 00000003 123789ABCF 1
10 00000004 123789ABCF 1
10 00000005 123789ABCF 1
20 00000006 123789ABCF 2
Using OUTFIL include we only pick the values 10 and 20 and remove the unwanted fields we created.
I suggest that you read the User Guide for DFSORT PTF UK90013 paper (sortugpf.pdf) which explains in detail about the GROUP and other new functions
http://www.ibm.com/support/docview.wss? ... g3T7000085