MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sort records in between header and trailer...

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
vak255
Intermediate


Joined: 10 Sep 2004
Posts: 384
Topics: 79

PostPosted: Mon Oct 10, 2005 8:46 am    Post subject: Sort records in between header and trailer... Reply with quote

Hi all,
I need to Sort only records in between header(MM) and trailer(MM)...
and write to output file with header and trailer. Any help is appreciated.

Code:

//DDDDDS2  EXEC PGM=SORT                               
//SYSOUT   DD  SYSOUT=*                                 
//SORTMSG  DD  SYSOUT=*                                 
//SYSABEND DD  SYSOUT=*                                 
//SYSUDUMP DD  SYSOUT=*                                 
//SYSIN    DD  DSN=AK.JCL(DDCNT),DISP=SHR     
//SORTIN   DD  DSN=AK.FILEI,DISP=SHR
//SORTOUT  DD  DSN=AK.SORT.FILEO(+1),   
//             DISP=(NEW,CATLG,DELETE),                 
//             SPACE=(CYL,(50,10),RLSE),               
//             UNIT=SYSDA,                             
//             DCB=(LRECL=100,DSORG=PS,RECFM=FB)     



DDCNT
Code:

SORT FIELDS=(16,13,CH,A)
SUM FIELDS=NONE         




AK.FILEI
Quote:

MM9999900510100823DDDDD FFFFF 003200527520
AAR FIRST C 1134341444441 XXXXXXXXX
ATX SECOND 7777777770111 XXXXXXXXX
ATX THIRD L 6297132201111 XXXXXXXXX
MM9999900510100823DDDDD FFFFF 003
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12380
Topics: 75
Location: San Jose

PostPosted: Mon Oct 10, 2005 8:50 am    Post subject: Reply with quote

vak255,

Please search before posting . check these links

http://mvsforums.com/helpboards/viewtopic.php?t=3432&highlight=header+sort

http://www.mvsforums.com/helpboards/viewtopic.php?t=2795&highlight=header+sort

http://mvsforums.com/helpboards/viewtopic.php?t=2880&highlight=header+sort

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Oct 10, 2005 10:36 am    Post subject: Reply with quote

The "Sort records between a header and trailer" Smart DFSORT Trick at:

http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/

shows how to do this kind of thing in one pass using DFSORT's IFTHEN and OVERLAY features.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Aug 11, 2008 6:19 pm    Post subject: Reply with quote

With z/OS DFSORT V1R5 PTF UK90013 (July, 2008), you can now use the new DATASORT operator of DFSORT's ICETOOL to easily keep headers, trailers or headers and trailers in place while you sort the data records between them. For complete details on DATASORT, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Mon Sep 08, 2008 10:17 am    Post subject: Reply with quote

Frank,
We have just got new PTF installed last weekend.

While I was trying couple of JCLs I got this strange error. I was trying to solve above mentioned problem with DATASORT facility.

Below is the JCL which I used.

Code:
//S1 EXEC PGM=ICETOOL                                       
//IN DD *                                                   
MM9999900510100823DDDDD FFFFF 003200527520                   
AAR FIRST C 1134341444441 XXXXXXXXX                         
ATX SECOND 7777777770111 XXXXXXXXX                           
ATX THIRD L 6297132201111 XXXXXXXXX                         
MM9999900510100823DDDDD FFFFF 003                           
//OUT       DD SYSOUT=*                                     
//TOOLIN DD *                                               
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)         
//CTL1CNTL DD                                               
SORT FIELDS=COPY                                             
//TOOLMSG   DD  SYSOUT=*                                     
//DFSMSG    DD  SYSOUT=*


I even tried, OPTION COPY instead of SORT FILEDS=COPY but none of them worked.

I got below mentioned error Message.
Code:

ICE632I 0 SOURCE FOR ICETOOL STATEMENTS:  TOOLIN                       
                                                                       
                                                                       
ICE630I 0 MODE IN EFFECT:  STOP                                       
                                                                       
          DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)         
ICE654A 0 SORT FUNCTION IS REQUIRED FOR DATASORT OPERATION             
ICE602I 0 OPERATION RETURN CODE:  12                                   
                                                                       
                                                                       
ICE601I 0 DFSORT ICETOOL UTILITY RUN ENDED - RETURN CODE:  12         


When looked at Error Message description it says :
Code:

ICE654A SORT FUNCTION IS REQUIRED FOR DATASORT OPERATION
Explanation: Critical. A DFSORT SORT statement was not found for this DATASORT operator, but you must
supply a SORT statement with DATASORT.
System Action: This operation is terminated.
Programmer Response: Specify a SORT statement in the xxxxCNTL data set corresponding to the USING(xxxx)
operand for this DATASORT operator. Ensure that the SORT statement is not overridden by an OPTION COPY
statement.

Could you please guide me if I am doing something wrong?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12380
Topics: 75
Location: San Jose

PostPosted: Mon Sep 08, 2008 10:21 am    Post subject: Reply with quote

Rajen,


The message ICE654A is self explanatory. You need to have a sort statement for DATASORT function. You have SORT FIELDS=COPY which is not valid for datasort. What fields are you trying sort in the detail records? If your intention is to drop header/trailer records then use the function SUBSET

Quote:

ICE654A SORT FUNCTION IS REQUIRED FOR DATASORT OPERATION
Explanation: Critical. A DFSORT SORT statement was not found for this DATASORT operator, but you must
supply a SORT statement with DATASORT.
System Action: This operation is terminated.
Programmer Response: Specify a SORT statement in the xxxxCNTL data set corresponding to the USING(xxxx)
operand for this DATASORT operator. Ensure that the SORT statement is not overridden by an OPTION COPY statement.

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Mon Sep 08, 2008 10:35 am    Post subject: Reply with quote

Kolusu,
I am trying to SORT based on first 3 bytes but nothing seems to work to I tried SORT FIELDS=COPY.

Below is the original JCL and respective error message.

Code:
//S1 EXEC PGM=ICETOOL                                         
//IN DD *                                                     
MM9999900510100823DDDDD FFFFF 003200527520                   
AAR FIRST C 1134341444441 XXXXXXXXX                           
ATX SECOND 7777777770111 XXXXXXXXX                           
ATX THIRD L 6297132201111 XXXXXXXXX                           
MM9999900510100823DDDDD FFFFF 003                             
//OUT       DD SYSOUT=*                                       
//TOOLIN DD *                                                 
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)         
//CTL1CNTL DD                                                 
SORT FIELDS=(1,3,CH,A)                                       
//TOOLMSG   DD  SYSOUT=*                                     
//DFSMSG    DD  SYSOUT=*               



Code:
ICE632I 0 SOURCE FOR ICETOOL STATEMENTS:  TOOLIN               
                                                               
                                                               
ICE630I 0 MODE IN EFFECT:  STOP                                 
                                                               
          DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1) 
ICE654A 0 SORT FUNCTION IS REQUIRED FOR DATASORT OPERATION     
ICE602I 0 OPERATION RETURN CODE:  12 



ICE601I 0 DFSORT ICETOOL UTILITY RUN ENDED - RETURN CODE: 12

What surprises me is the error message that says SORT FUNCTION IS REQUIRED FOR DATASORT. I was assuming that it would look for keyword SORT in the control card.

Now, Here I am trying to SORT based on first 3 bytes, which gave me same error.

I am afraid now that I may be doing something wrong from basic Sad.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12380
Topics: 75
Location: San Jose

PostPosted: Mon Sep 08, 2008 10:43 am    Post subject: Reply with quote

rajen wrote:
I am afraid now that I may be doing something wrong from basic


Rajen,

Your SORT Control cards start in POS 1 which is NOT valid. Toolin statements can start from pos 1 but not the XXXXCNTL cards.

Code your sort fields statement from pos 2 and the job will run fine. And the input is already sorted on the first 3 bytes. so you will see the same as input. If you want to see how the data is sorted then try this job

Code:

//STEP0300 EXEC PGM=ICETOOL                             
//TOOLMSG   DD  SYSOUT=*                               
//DFSMSG    DD  SYSOUT=*                               
//IN DD *                                               
MM9999900510100823DDDDD FFFFF 003200527520             
ATX SECOND 7777777770111 XXXXXXXXX                     
ATX THIRD L 6297132201111 XXXXXXXXX                     
AAR FIRST C 1134341444441 XXXXXXXXX                     
MM9999900510100823DDDDD FFFFF 003                       
//OUT       DD SYSOUT=*                                 
//TOOLIN    DD *                                       
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)   
//CTL1CNTL  DD *                                       
 SORT FIELDS=(1,3,CH,A)                                 


Hope this helps...

Cheers
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Mon Sep 08, 2008 10:51 am    Post subject: Reply with quote

Oh..my..bad!!

After doing it many times for other DFSORT tricks, I missed that part here.

Thanks again Kolusu.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group