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
 

 

SORT GROUP RECORDS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 171
Location: Bangalore

PostPosted: Fri Jun 22, 2012 2:27 pm    Post subject: SORT GROUP RECORDS
Reply with quote

Hi,

I am not sure if the below logic can be done in a single step. Please let me know if this logic can be modified in a simpler way.

Code:
//STEP20   EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SYSPRINT DD SYSOUT=*                                   
//SORTIN   DD *                                           
C33 NOT IN A GROUP                                       
HDR START GROUP1                                         
A01 GROUP 1 RECORD 8711                                   
B02 GROUP 1 RECORD                                       
C03 GROUP 1 RECORD                                       
TRL END GROUP1                                           
R24 NOT IN A GROUP                                       
T02 NOT IN A GROUP                                       
HDR START GROUP2                                         
D04 GROUP 2 RECORD                                       
E05 GROUP 2 RECORD                                       
TRL END GROUP2                                           
F97 NOT IN A GROUP                                       
HDR START GROUP3                                         
D04 GROUP 3 RECORD 8711                                   
E05 GROUP 3 RECORD                                       
TRL END GROUP3                                           
F97 NOT IN A GROUP                                       
//SORTOUT  DD DSN=&&TEMP1,DISP=(NEW,PASS)                 
//SYSIN    DD *                                           
  OPTION COPY                                             
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),     
  PUSH=(31:1,30,81:ID=1),END=(1,3,CH,EQ,C'TRL')),         
  IFTHEN=(WHEN=(20,4,CH,NE,C'8711',AND,                   
                31,3,CH,EQ,C'HDR'),OVERLAY=(31:20X))     
/*                                                       
//STEP30   EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SYSPRINT DD SYSOUT=*                                   
//SORTIN   DD DSN=&&TEMP1,DISP=(OLD,DELETE)               
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                           
  OPTION COPY                                             
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(20,4,CH,EQ,C'8711'),   
                           END=(1,3,CH,EQ,C'TRL'),PUSH=(82:ID=1))
   OUTFIL IFOUTLEN=30,OMIT=(82,1,CH,EQ,C' '),                     
   IFTHEN=(WHEN=(82,1,CH,NE,C' ',AND,20,4,CH,EQ,C'8711'),         
           BUILD=(1:31,25,/,1:1,80)),                             
   IFTHEN=(WHEN=(20,4,CH,EQ,C'    '),BUILD=(1,30))               
/*                                                               


Output:-
Code:
HDR START GROUP1       
A01 GROUP 1 RECORD 8711
B02 GROUP 1 RECORD     
C03 GROUP 1 RECORD     
TRL END GROUP1         
HDR START GROUP3       
D04 GROUP 3 RECORD 8711
E05 GROUP 3 RECORD     
TRL END GROUP3         
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jun 22, 2012 2:30 pm    Post subject:
Reply with quote

what?
we are supposed to generate our own requirements based on your control cards,
and then improve your control cards.

this is an interesting twist on the "please do my work for me".
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Fri Jun 22, 2012 3:22 pm    Post subject: Reply to: SORT GROUP RECORDS
Reply with quote

You are COPYing only. If you change the INREC in 2nd step to OUTREC you can put the code into the first step. If the existing code is working, that should be worth trying. Should already have been worth trying....
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 22, 2012 9:19 pm    Post subject: Reply to: SORT GROUP RECORDS
Reply with quote

If your intention is to get the groups with 8711 then you can do it all in a single step. I assumed that your code 8711 occurs on the 2nd record in the group.

Use the following DFSORT JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD *                                       
C33 NOT IN A GROUP                                   
HDR START GROUP1                                     
A01 GROUP 1 RECORD 8711                               
B02 GROUP 1 RECORD                                   
C03 GROUP 1 RECORD                                   
TRL END GROUP1                                       
R24 NOT IN A GROUP                                   
T02 NOT IN A GROUP                                   
HDR START GROUP2                                     
D04 GROUP 2 RECORD                                   
E05 GROUP 2 RECORD                                   
TRL END GROUP2                                       
F97 NOT IN A GROUP                                   
HDR START GROUP3                                     
D04 GROUP 3 RECORD 8711                               
E05 GROUP 3 RECORD                                   
TRL END GROUP3                                       
F97 NOT IN A GROUP                                   
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                       
  OPTION COPY                                         
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'), 
  END=(1,3,CH,EQ,C'TRL'),PUSH=(31:1,30,SEQ=8)),       
  IFTHEN=(WHEN=GROUP,BEGIN=(61,8,ZD,EQ,2),           
  END=(1,3,CH,EQ,C'TRL'),PUSH=(70:20,4))             
                                                     
  OUTFIL IFOUTLEN=30,INCLUDE=(70,4,CH,EQ,C'8711'),   
  IFTHEN=(WHEN=(61,8,ZD,EQ,2),BUILD=(31,30,/,1,30))   
//*
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 171
Location: Bangalore

PostPosted: Fri Jun 22, 2012 9:50 pm    Post subject: Reply to: SORT GROUP RECORDS
Reply with quote

Yes that's exactly I was trying Skolusu, But the code 8711 can occur in any record after HDR but before TRL. In my example I tried it was unfortunately on 2nd record.

Please let me know if you have any solution or logic?
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 22, 2012 10:28 pm    Post subject: Re: Reply to: SORT GROUP RECORDS
Reply with quote

shrivatsa wrote:
Yes that's exactly I was trying Skolusu, But the code 8711 can occur in any record after HDR but before TRL. In my example I tried it was unfortunately on 2nd record.

Please let me know if you have any solution or logic?


Are you aware that your current solution you coded does NOT handle that. If your 8711 record occurs anywhere then you have to SORT the file.

Let me know if you are interested in a SORT solution.
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 22, 2012 11:23 pm    Post subject:
Reply with quote

Oh well here is the solution to handle 8711 occurring any where
Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
C33 NOT IN A GROUP                                                   
HDR START GROUP1                                                     
B02 GROUP 1 RECORD                                                   
C03 GROUP 1 RECORD                                                   
A01 GROUP 1 RECORD 8711                                               
TRL END GROUP1                                                       
R24 NOT IN A GROUP                                                   
T02 NOT IN A GROUP                                                   
HDR START GROUP2                                                     
D04 GROUP 2 RECORD                                                   
E05 GROUP 2 RECORD                                                   
TRL END GROUP2                                                       
F97 NOT IN A GROUP                                                   
HDR START GROUP3                                                     
D04 GROUP 3 RECORD 8711                                               
E05 GROUP 3 RECORD                                                   
TRL END GROUP3                                                       
F97 NOT IN A GROUP                                                   
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(47:C'A')),                         
  IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),                       
  END=(1,3,CH,EQ,C'TRL'),PUSH=(31:ID=8,SEQ=8)),                       
  IFTHEN=(WHEN=(20,4,CH,EQ,C'8711'),OVERLAY=(47:X))                   
  SORT FIELDS=(31,8,CH,A,47,1,CH,A),EQUALS                           
                                                                     
  OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(31,8),PUSH=(48:1,46)),         
  IFTHEN=(WHEN=INIT,OVERLAY=(94:39,8,UFF,SUB,86,8,UFF,ZD,LENGTH=8))   
                                                                     
  OUTFIL IFOUTLEN=30,INCLUDE=(67,4,CH,EQ,C'8711',AND,47,1,CH,EQ,C'A'),
  IFTHEN=(WHEN=(94,8,ZD,EQ,+1),BUILD=(48,30,/,1,30))                 
//*
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 171
Location: Bangalore

PostPosted: Sat Jun 23, 2012 10:49 pm    Post subject: Reply to: SORT GROUP RECORDS
Reply with quote

oh.. Thanks Skolusu.. I was trying for the same but unfortunately I have taken worng input records.

Thanks for your time in providing the solution.
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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm


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