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

DFSORT to handle in between specific rows


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

Active User


Joined: 22 Dec 2007
Posts: 116
Location: Bangalore

PostPosted: Thu Feb 06, 2020 1:22 am
Reply with quote

Hi,

I need your advice on what approach should I take (or if it is possible at all) to sort below type of recs.

Code:
Header1..............................................
01 NAME1 ADDRESS1 TA2222 S PHONE1
01 NAME2 ADDRESS2 TA2222 S PHONE2
01 NAME3 ADDRESS3 TA2222 S PHONE3
01 NAME4 ADDRESS4 TA2222 N PHONE4
01 NAME5 ADDRESS5 TA2222 S PHONE5
02 TA2222 <SUMMARY DETAILS OF ABOVE ROWS>
01 NAME1 ADDRESS1 TA1222 S PHONE1
01 NAME2 ADDRESS2 TA1222 N PHONE2
01 NAME3 ADDRESS3 TA1222 S PHONE3
01 NAME4 ADDRESS4 TA1222 N PHONE4
01 NAME5 ADDRESS5 TA1222 S PHONE5
02 TA1222 <SUMMARY DETAILS OF ABOVE ROWS>
01 NAME1 ADDRESS1 TA2223 S PHONE1
01 NAME2 ADDRESS2 TA2223 S PHONE2
01 NAME3 ADDRESS3 TA2223 S PHONE3
01 NAME4 ADDRESS4 TA2223 S PHONE4
01 NAME5 ADDRESS5 TA2223 N PHONE5
02 TA2223 <SUMMARY DETAILS OF ABOVE ROWS>
03 <WEEKLY SUMMARY DETAILS>
04 <MONTHLY SUMMARY DETAILS>


For ease of programming I want to SORT the above given recs. Now the first line is header and last 2 are trailers. How I need to sort is, post sort the data should look like below..

Code:
Header1..............................................
01 NAME1 ADDRESS1 TA2222 S PHONE1
01 NAME2 ADDRESS2 TA2222 S PHONE2
01 NAME3 ADDRESS3 TA2222 S PHONE3
01 NAME5 ADDRESS5 TA2222 S PHONE5
01 NAME4 ADDRESS4 TA2222 N PHONE4
02 TA2222 <SUMMARY DETAILS OF ABOVE ROWS>
01 NAME1 ADDRESS1 TA1222 S PHONE1
01 NAME3 ADDRESS3 TA1222 S PHONE3
01 NAME5 ADDRESS5 TA1222 S PHONE5
01 NAME2 ADDRESS2 TA1222 N PHONE2
01 NAME4 ADDRESS4 TA1222 N PHONE4
02 TA1222 <SUMMARY DETAILS OF ABOVE ROWS>
01 NAME1 ADDRESS1 TA2223 S PHONE1
01 NAME2 ADDRESS2 TA2223 S PHONE2
01 NAME3 ADDRESS3 TA2223 S PHONE3
01 NAME4 ADDRESS4 TA2223 S PHONE4
01 NAME5 ADDRESS5 TA2223 N PHONE5
02 TA2223 <SUMMARY DETAILS OF ABOVE ROWS>
03 <WEEKLY SUMMARY DETAILS>
04 <MONTHLY SUMMARY DETAILS>


Means Header and 2 trailers should be in tact. Our 02 rec should be in tact. Sort will happen only on the TA number (Transfer Agent) against BILL (Either S or N).

What I can remember using DATASORT I can keep my Header and Trailer in tact and sort in between but I am not getting how to keep 02 rec in it's place and do the sort.
Can anyone please guide me?

Thanks
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 385
Location: Bamberg, Germany

PostPosted: Thu Feb 06, 2020 11:51 am
Reply with quote

This works with your given data.

Code:
OPTION EQUALS                                                       
INREC IFTHEN=(WHEN=GROUP,END=(1,2,SS,EQ,C'02,03,04'),PUSH=(65:ID=4)),
  IFTHEN=(WHEN=(1,7,CH,EQ,C'Header1'),OVERLAY=(69:+0,ZD,LENGTH=2)), 
  IFTHEN=(WHEN=(1,2,CH,EQ,C'01'),OVERLAY=(69:1,2)),                 
  IFTHEN=(WHEN=NONE,OVERLAY=(69:+99,ZD,LENGTH=2))                   
SORT FIELDS=(65,6,ZD,A,19,6,CH,A,26,1,CH,D)                         
OUTFIL BUILD=(1,64)                                                 
END

Code:
Header1..............................................   
01 NAME1 ADDRESS1 TA2222 S PHONE1                       
01 NAME2 ADDRESS2 TA2222 S PHONE2                       
01 NAME3 ADDRESS3 TA2222 S PHONE3                       
01 NAME5 ADDRESS5 TA2222 S PHONE5                       
01 NAME4 ADDRESS4 TA2222 N PHONE4                       
02 TA2222 <SUMMARY DETAILS OF ABOVE ROWS>               
01 NAME1 ADDRESS1 TA1222 S PHONE1                       
01 NAME3 ADDRESS3 TA1222 S PHONE3                       
01 NAME5 ADDRESS5 TA1222 S PHONE5                       
01 NAME2 ADDRESS2 TA1222 N PHONE2                       
01 NAME4 ADDRESS4 TA1222 N PHONE4                       
02 TA1222 <SUMMARY DETAILS OF ABOVE ROWS>               
01 NAME1 ADDRESS1 TA2223 S PHONE1                       
01 NAME2 ADDRESS2 TA2223 S PHONE2                       
01 NAME3 ADDRESS3 TA2223 S PHONE3                       
01 NAME4 ADDRESS4 TA2223 S PHONE4                       
01 NAME5 ADDRESS5 TA2223 N PHONE5                       
02 TA2223 <SUMMARY DETAILS OF ABOVE ROWS>               
03 <WEEKLY SUMMARY DETAILS>                             
04 <MONTHLY SUMMARY DETAILS>                           
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 385
Location: Bamberg, Germany

PostPosted: Fri Feb 07, 2020 12:27 am
Reply with quote

Minor update:
Code:
OPTION EQUALS                                                 
INREC IFTHEN=(WHEN=GROUP,END=(1,2,CH,NE,C'01'),PUSH=(65:ID=4)),
  IFTHEN=(WHEN=(1,2,CH,EQ,C'01'),OVERLAY=(69:1,2)),           
  IFTHEN=(WHEN=NONE,OVERLAY=(69:+99,ZD,LENGTH=2))             
SORT FIELDS=(65,6,ZD,A,19,6,CH,A,26,1,CH,D)                   
OUTFIL BUILD=(1,64)                                           
END
Back to top
View user's profile Send private message
subratarec

Active User


Joined: 22 Dec 2007
Posts: 116
Location: Bangalore

PostPosted: Fri Feb 07, 2020 1:20 am
Reply with quote

Hi Joerg,

First of all thanks! a lot for your reply. Yes it is working correctly. At the same time I was also trying to fix this issue and I used DATASORT in ICETOOL to achieve the same result. Which I will post here. Then atleast we will have 2 solutions...

Code:
//TOOLIN DD *
   DATASORT FROM(IN1) TO(OUT1) HEADER(1) TRAILER(2) USING(CTL1)
   COPY FROM(OUT1) TO(OUT2) USING(CTL2)
//CTL1CNTL  DD *
   INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,ZD,EQ,02),PUSH=(65:ID=8))
   SORT FIELDS=(65,8,ZD,A,19,6,CH,A,26,1,CH,D)
//CTL2CNTL  DD *
   SORT FIELDS=COPY
   OUTREC BUILD=(1,64)
/*


Thanks again for your solution. It helped me a lot!! Now I have 2 solutions with me.
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 385
Location: Bamberg, Germany

PostPosted: Fri Feb 07, 2020 1:51 am
Reply with quote

I try to avoid the overhead of ICETOOL because nearly everything can be done with ICEMAN as well. As I see, DATASORT has a fixed number of Header- and Trailer lines. My last solution allows flexible numbers (so far that's tested). icon_wink.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 385
Location: Bamberg, Germany

PostPosted: Fri Feb 07, 2020 2:48 am
Reply with quote

@subratarec: Please verify your code against this modified Input data. Looks pretty close to yours but results are different!

Input:
Code:
Header1..Alpha.......................................   
01 NAME1 ADDRESS1 TA2222 S PHONE1                       
01 NAME2 ADDRESS2 TA2222 S PHONE2                       
01 NAME3 ADDRESS3 TA2222 S PHONE3                       
01 NAME4 ADDRESS4 TA2222 N PHONE4                       
01 NAME5 ADDRESS5 TA2222 S PHONE5                       
02 TA2222  <SUMMARY DETAILS OF ABOVE ROWS>             
01 NAME1 ADDRESS1 TA1222 S PHONE1                       
01 NAME2 ADDRESS2 TA1222 N PHONE2                       
01 NAME3 ADDRESS3 TA1222 S PHONE3                       
01 NAME4 ADDRESS4 TA1222 N PHONE4                       
01 NAME5 ADDRESS5 TA1222 S PHONE5                       
02 TA1222  <SUMMARY DETAILS OF ABOVE ROWS>             
01 NAME1 ADDRESS1 TA2223 S PHONE1                       
01 NAME2 ADDRESS2 TA2223 S PHONE2                       
01 NAME3 ADDRESS3 TA2223 S PHONE3                       
01 NAME4 ADDRESS4 TA2223 S PHONE4                       
01 NAME5 ADDRESS5 TA2223 N PHONE5                       
02 TA2223  <SUMMARY DETAILS OF ABOVE ROWS>             
03 <WEEKLY SUMMARY DETAILS>                             
04 <MONTHLY SUMMARY DETAILS>                           


Result:
Code:
Header1..Alpha.......................................
01 NAME1 ADDRESS1 TA2222 S PHONE1                     
01 NAME2 ADDRESS2 TA2222 S PHONE2                     
01 NAME3 ADDRESS3 TA2222 S PHONE3                     
01 NAME5 ADDRESS5 TA2222 S PHONE5                     
01 NAME4 ADDRESS4 TA2222 N PHONE4                     
01 NAME1 ADDRESS1 TA1222 S PHONE1                     
01 NAME3 ADDRESS3 TA1222 S PHONE3                     
01 NAME5 ADDRESS5 TA1222 S PHONE5                     
01 NAME2 ADDRESS2 TA1222 N PHONE2                     
01 NAME4 ADDRESS4 TA1222 N PHONE4                     
02 TA2222  <SUMMARY DETAILS OF ABOVE ROWS>           
01 NAME1 ADDRESS1 TA2223 S PHONE1                     
01 NAME2 ADDRESS2 TA2223 S PHONE2                     
01 NAME3 ADDRESS3 TA2223 S PHONE3                     
01 NAME4 ADDRESS4 TA2223 S PHONE4                     
01 NAME5 ADDRESS5 TA2223 N PHONE5                     
02 TA1222  <SUMMARY DETAILS OF ABOVE ROWS>           
02 TA2223  <SUMMARY DETAILS OF ABOVE ROWS>           
03 <WEEKLY SUMMARY DETAILS>                           
04 <MONTHLY SUMMARY DETAILS>                         
Back to top
View user's profile Send private message
subratarec

Active User


Joined: 22 Dec 2007
Posts: 116
Location: Bangalore

PostPosted: Sat Feb 08, 2020 1:07 am
Reply with quote

@Joerg.Findeisen - Hi Thanks for your reply. Ok let me test with this modified input data.

Thanks
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 REMOVE DUPLICATE RECORDS BASED ON A S... DFSORT/ICETOOL 4
No new posts NOT ABLE TO FIND DB2 ROWS DB2 2
No new posts Need to read duplicate rows from tabl... DB2 3
No new posts Join lines with dfsort DFSORT/ICETOOL 5
No new posts to Insert Rows from File1 to File 2 ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top