Portal | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
DFSORT to handle in between specific rows

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: DFSORT to handle in between specific rows
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: 340
Location: Bamberg, Germany

PostPosted: Thu Feb 06, 2020 11:51 am    Post subject:
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: 340
Location: Bamberg, Germany

PostPosted: Fri Feb 07, 2020 12:27 am    Post subject:
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    Post subject:
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: 340
Location: Bamberg, Germany

PostPosted: Fri Feb 07, 2020 1:51 am    Post subject:
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: 340
Location: Bamberg, Germany

PostPosted: Fri Feb 07, 2020 2:48 am    Post subject:
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    Post subject:
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    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 NOT ABLE TO FIND DB2 ROWS Suehowe DB2 2 Sat Oct 10, 2020 2:05 am
No new posts Need to read duplicate rows from tabl... Poha Eater DB2 2 Wed Oct 07, 2020 11:08 pm
No new posts Join lines with dfsort kushkush DFSORT/ICETOOL 5 Mon Oct 05, 2020 12:16 pm
No new posts to Insert Rows from File1 to File 2 ... Arun_Tupili DFSORT/ICETOOL 1 Thu Aug 13, 2020 6:22 pm
No new posts Covert k to 1000 / m to 1000000 using... A_programmers DFSORT/ICETOOL 5 Tue Jun 23, 2020 6:52 pm

Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us