Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Control Break with DFSORT with sequence number

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Control Break with DFSORT with sequence number
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    Post subject: Reply to: Control Break with DFSORT with sequence number
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Tue Jun 21, 2011 11:12 pm    Post subject:
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 Moderator


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

PostPosted: Wed Jun 22, 2011 1:00 am    Post subject:
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:

http://ibmmainframes.com/viewtopic.php?t=33389

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

http://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    Post subject: Reply to: Control Break with DFSORT with sequence number
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Jun 22, 2011 1:05 pm    Post subject: Reply to: Control Break with DFSORT with sequence number
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Jun 22, 2011 1:13 pm    Post subject: Reply to: Control Break with DFSORT with sequence number
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Jun 22, 2011 1:27 pm    Post subject: Reply to: Control Break with DFSORT with sequence number
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Jun 22, 2011 2:59 pm    Post subject: Reply to: Control Break with DFSORT with sequence number
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    Post subject: Reply to: Control Break with DFSORT with sequence number
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts Sequence number add in SORT pshongal SYNCSORT 3 Fri Sep 02, 2016 3:32 pm
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us