View previous topic :: View next topic
Author
Message
prasun dhara New User Joined: 01 Mar 2008Posts: 49 Location: kolkata
We have two key fields key1 and key2. Data is sorted first based on the key1 then based on the key 2.
Now my requirement is like below:
a) Whenever key1 value changed from its previous value seqnum resets to 001
b) For every key1 value if the following key 2 value changes the seqnum increments by one.
c) If it doesn’t changed it keeps the original value
Please see below example
INPUT FILE
Key1 key2
234 112
234 112
234 113
234 114
234 114
234 115
235 112
235 112
235 113
235 113
236 117
237 117
238 117
OUTPUT FILE
Key1 key2 SEQNUM
234 112 001
234 112 001
234 113 002
234 114 003
234 114 003
234 115 004
235 112 001
235 112 001
235 113 002
235 113 002
236 117 001
237 117 001
238 117 001
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
prasun dhara,
The following DFSORT JCL will give you the desired results
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
234 112
234 112
234 113
234 114
234 114
234 115
235 112
235 112
235 113
235 113
236 117
237 117
238 117
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFOUTLEN=80,
IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,7),PUSH=(81:ID=8)),
IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,3),PUSH=(89:81,8)),
IFTHEN=(WHEN=INIT,
OVERLAY=(12:+1,ADD,(81,8,ZD,SUB,89,8,ZD),M11,LENGTH=3))
//*
Back to top
prasun dhara New User Joined: 01 Mar 2008Posts: 49 Location: kolkata
I tried this but the KEYBEGIN is not working. I think it's an installation specific issue. I am getting error like "KEYBEGIN" is unknown.
I used "BEGIN" keyword in some other sort that works perfectly. Could you please help me write the sort step using BEGIN or anything other than "KEYBEGIN".
Thanks
Prasun
Back to top
expat Global Moderator Joined: 14 Mar 2007Posts: 8797 Location: Welsh Wales
Please post the output from the run including the message numbers.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Back to top
prasun dhara New User Joined: 01 Mar 2008Posts: 49 Location: kolkata
Hi,
I have just verified from the SYSOUT message ( ICE*** G) , that we do not have the OCT 2010 version. Instead it is Nov 2009.So KEYBEGIN will not work.
Is there anyway that my Sort requirement can be achieved without KEYBEGIN ??
Thanks
Prasun
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Quote:
In order to use KEYBEGIN, you must have z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026 (Oct, 2010) installed. If you don't have this PTF, ask your System Programmer to install it .
Emphasis added.
Back to top
enrico-sorichetti Superior Member Joined: 14 Mar 2007Posts: 10873 Location: italy
Quote:
Is there anyway that my Sort requirement can be achieved without KEYBEGIN ??
Quote:
If you don't have this PTF, ask your System Programmer to install it.
in many organization there are dynamics which make installing maintenance
a bit painful!
so asking support to install something more than often does not have any effect!
especially if You are low in the food chain
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Well, you can ask. If they say no, then look for a solution without KEYBEGIN.
You don't do the asking yourself. You get your boss, he gets his boss, etc up the food-chain, depending on the importance of the user/requirement.
Back to top
enrico-sorichetti Superior Member Joined: 14 Mar 2007Posts: 10873 Location: italy
I am not a sort expert but You might try with something along the lines of
Code:
000026 //SYSIN DD *
000027 SORT FIELDS=COPY
000028 INREC IFOUTLEN=80,
000029 IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,7))),
000030 IFTHEN=(WHEN=INIT,OVERLAY=(91:SEQNUM,8,ZD,RESTART=(1,3))),
000031 IFTHEN=(WHEN=GROUP,BEGIN(81,8,ZD,EQ,1),PUSH=(101:ID=8)),
000032 IFTHEN=(WHEN=GROUP,BEGIN(91,8,ZD,EQ,1),PUSH=(111:101,8)),
000033 IFTHEN=(WHEN=INIT,
000034 OVERLAY=(09:+1,ADD,(101,8,ZD,SUB,111,8,ZD),M11,LENGTH=3))
certainly Frank or Kolusu will offer a better advice
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
enrico-sorichetti has the right idea. You just don't need to push all the way to 119 bytes as you can overlay the contents.
prasun dhara,
Use the following control cards
Code:
//SYSIN DD *
SORT FIELDS=COPY
INREC IFOUTLEN=80,
IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,7))),
IFTHEN=(WHEN=INIT,OVERLAY=(89:SEQNUM,8,ZD,RESTART=(1,3))),
IFTHEN=(WHEN=GROUP,BEGIN=(81,8,ZD,EQ,1),PUSH=(81:ID=8)),
IFTHEN=(WHEN=GROUP,BEGIN=(89,8,ZD,EQ,1),PUSH=(89:81,8)),
IFTHEN=(WHEN=INIT,
OVERLAY=(12:+1,ADD,(81,8,ZD,SUB,89,8,ZD),M11,LENGTH=3))
//*
Back to top
Please enable JavaScript!