The reason I'm struggling here is that the values I have provided in my example of A/B/C are very variable inputs (hundreds of possibilities here), so I can't just use a simple replace. What that incoming value is, is not important. What is important is that I have a 'sequence number' (or incremental numerical label starting at 1), which increments whenever the value in pos 1 changes.
I tried using SEQNUM, with a RESTART on the value in pos 1, but that gave me the following, quickly followed with me slapping my head when I realised I was asking the impossible of good old RESTART :
Can anyone point me in the direction of an alternative approach with DFSORT (or even ICETOOL - i'm not a fussy man ) which will give me the results i'm after.
Thanks Bill, I'll give that a go in the morning. I've been using DFSORT for years, but only very recently discovered SEQNUM, and I've never seen the GROUP function.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
HammerTime wrote:
Hi all, i'm pulling my hair out with what I can only imagine is a simple bit of logic!
I have an input which looks something like this:
Code:
1234567890
----------
A CODE1
A CODE4
B CODE3
B CODE9
B CODEX
C CODEEE
The reason I'm struggling here is that the values I have provided in my example of A/B/C are very variable inputs (hundreds of possibilities here), so I can't just use a simple replace. What that incoming value is, is not important. What is important is that I have a 'sequence number' (or incremental numerical label starting at 1), which increments whenever the value in pos 1 changes.
Hammertime,
As bill suggested it is quite easy. However if you have hundreds of possible values how are you going to fit it in 2 bytes? Don't you need more than that?
Either way here is a sample for 2 byte id. You can adjust length of n in ID=n based on your requirements.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
A CODE1
A CODE4
B CODE3
B CODE9
B CODEX
C CODEEE
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,1),PUSH=(ID=2))
//*
Thank you so much guys, that is exactly what I wanted. Interesting to see that the PUSH=(ID=X) actually overlays the incoming data with the sequence. Perfect for my needs (as mentioned, I'm not actually interested in my incoming identifier, only in the grouping), but worth noting for others.
Skolusu, the incoming identifier field which I represented in my example above as A/B/C is actually 7 bytes. As mentioned, the PUSH overlays the first X bytes of that, for my purposes I needed X to be 3 (this will be compared against a matching sequence later in my JCL), so to clean things up for my purposes I just space filled the remainder of my incoming identifier (eg: the 4 byes after X).