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

Grouping by multiple headers


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

New User


Joined: 03 Jul 2006
Posts: 55

PostPosted: Thu Oct 26, 2023 6:23 pm
Reply with quote

Hello.
After trying GROUP, IFTEN and being completely lost I would like to ask members here if anybody has sample code that will do the following. Find specific header and write output for that header and details to output. In case below it's BMW only header and details that needed.

Input file:
Code:

2023-10-10 HEADER - AUDI
    00000000000001 DETAIL
    00000000000001 DETAIL
    00000000000001 DETAIL
    00000000000001 DETAIL
2023-10-10 HEADER - BMW
    00000000000002 DETAIL
    00000000000002 DETAIL
    00000000000002 DETAIL
2023-10-10 HEADER - MERCEDES
    00000000000003 DETAIL
    00000000000003 DETAIL
    00000000000003 DETAIL
    00000000000003 DETAIL
    00000000000003 DETAIL



Output file:
Code:

2023-10-10 HEADER - BMW
    00000000000002 DETAIL
    00000000000002 DETAIL
    00000000000002 DETAIL


Thanks a lot in advance.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Thu Oct 26, 2023 6:55 pm
Reply with quote

And the problem is to do so?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2119
Location: USA

PostPosted: Thu Oct 26, 2023 6:57 pm
Reply with quote

rmd3003 wrote:

After trying GROUP, IFTEN and being completely lost

Where is what you have tried so far?
Back to top
View user's profile Send private message
rmd3003

New User


Joined: 03 Jul 2006
Posts: 55

PostPosted: Thu Oct 26, 2023 8:06 pm
Reply with quote

Well, problem is that I pick up everything after BMW header. So GROUP works but doesn;t stop processing.

Code:

//SYSIN DD *                                               
 OPTION COPY                                               
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(21,8,CH,EQ,C'BMW     '), 
 PUSH=(61:21,8))                                           
 OUTFIL INCLUDE=(61,8,CH,EQ,C'BMW     '),                 
 BUILD=(1,60)                                             


Output looks like this:
Code:

2023-10-10 HEADER - BMW         
    00000000000002 DETAIL       
    00000000000002 DETAIL       
    00000000000002 DETAIL       
2023-10-10 HEADER - MERCEDES     
    00000000000003 DETAIL       
    00000000000003 DETAIL       
    00000000000003 DETAIL       
    00000000000003 DETAIL       
    00000000000003 DETAIL       



Tried adding second IFTHEN '21,8,CH,NE,C'BMW ' but it produces nothing.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2119
Location: USA

PostPosted: Thu Oct 26, 2023 8:39 pm
Reply with quote

rmd3003 wrote:
Well, problem is that I pick up everything after BMW header. So GROUP works but doesn;t stop processing.

Code:

//SYSIN DD *                                               
 OPTION COPY                                               
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(21,8,CH,EQ,C'BMW     '), 
 PUSH=(61:21,8))                                           
 OUTFIL INCLUDE=(61,8,CH,EQ,C'BMW     '),                 
 BUILD=(1,60)                                             


Output looks like this:
Code:

2023-10-10 HEADER - BMW         
    00000000000002 DETAIL       
    00000000000002 DETAIL       
    00000000000002 DETAIL       
2023-10-10 HEADER - MERCEDES     
    00000000000003 DETAIL       
    00000000000003 DETAIL       
    00000000000003 DETAIL       
    00000000000003 DETAIL       
    00000000000003 DETAIL       



Tried adding second IFTHEN '21,8,CH,NE,C'BMW ' but it produces nothing.

You MUST specify the condition to END THE CURRENT GROUP. Otherwise the group once started continues to the very end of the dataset.

OR

You must specify the beginning of ANY GROUP, not only BMW. But for your OUTFIL you can select only BMW.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Fri Oct 27, 2023 6:41 am
Reply with quote

As @sergeyken has pointed out, this basically is easy to solve.

Code:
OPTION COPY                                                   
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,FS,EQ,NUM),PUSH=(60:21,8))
OUTFIL INCLUDE=(60,8,CH,EQ,C'BMW')                           
END

Code:
****** **************************** Datenanfang ***********************
000001 2023-10-10 HEADER - BMW                                    BMW 
000002     00000000000002 DETAIL                                  BMW 
000003     00000000000002 DETAIL                                  BMW 
000004     00000000000002 DETAIL                                  BMW 
****** **************************** Datenende *************************
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2119
Location: USA

PostPosted: Fri Oct 27, 2023 6:46 am
Reply with quote

Joerg.Findeisen wrote:
As @sergeyken has pointed out, this basically is easy to solve.

Code:
OPTION COPY                                                   
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,FS,EQ,NUM),PUSH=(60:21,8))
OUTFIL INCLUDE=(60,8,CH,EQ,C'BMW')                           
END

Code:
****** **************************** Datenanfang ***********************
000001 2023-10-10 HEADER - BMW                                    BMW 
000002     00000000000002 DETAIL                                  BMW 
000003     00000000000002 DETAIL                                  BMW 
000004     00000000000002 DETAIL                                  BMW 
****** **************************** Datenende *************************

I suggest to better detect groups not by NUM value, but by C'HEADER' value.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Fri Oct 27, 2023 6:56 am
Reply with quote

It was a quick hack at this time. It's 0325 am here icon_smile.gif
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 SORT JCL to merge multiple tow into s... DFSORT/ICETOOL 6
No new posts Using Multiple IFTHEN and WHEN condit... SYNCSORT 12
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Multiple table unload using INZUTILB DB2 2
Search our Forums:

Back to Top