IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Control Break with DFSORT with sequence number


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prasun dhara

New User


Joined: 01 Mar 2008
Posts: 49
Location: kolkata

PostPosted: Fri Jun 03, 2011 1:02 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jun 03, 2011 10:33 pm
Reply with quote

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
View user's profile Send private message
prasun dhara

New User


Joined: 01 Mar 2008
Posts: 49
Location: kolkata

PostPosted: Tue Jun 21, 2011 11:09 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Jun 21, 2011 11:12 pm
Reply with quote

Please post the output from the run including the message numbers.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jun 22, 2011 1:00 am
Reply with quote

prasun dhara,

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.

For details on determining whether you have this DFSORT PTF, see:

ibmmainframes.com/viewtopic.php?t=33389

For details on the new functions available with this DFSORT PTF, see:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242
Back to top
View user's profile Send private message
prasun dhara

New User


Joined: 01 Mar 2008
Posts: 49
Location: kolkata

PostPosted: Wed Jun 22, 2011 11:50 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 22, 2011 1:05 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jun 22, 2011 1:13 pm
Reply with quote

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 icon_biggrin.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 22, 2011 1:27 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jun 22, 2011 2:59 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 22, 2011 10:21 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top