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
 

 

Change group of records from control record

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

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Fri May 11, 2012 4:21 am    Post subject: Change group of records from control record
Reply with quote

Hi, I have input file with group of records. Group started with HDR word. Within group the word CTL indicate control. :
Code:
000001 HDR  1234  <----FIRST GROUP             
000002 INF  1111                               
000003 INF  2222                               
000004 CTL  AAAA  CONTROL                       
000005 INF  1111                               
000006 HDR  0034  <----SECOND GROUP             
000007 INF  1111                               
000008 INF  1111                               
000009 INF  2222                               
000010 CTL  BBBB   CONTROL                     
000011 INF  1111                               
000012 INF  1111                               


I need to add info from Control record to each record in the group:

Input file:
Code:
000001 HDR  1234 
000002 INF  1111 
000003 INF  2222 
000004 CTL  AAAA 
000005 INF  1111 
000006 HDR  0034 
000007 INF  1111 
000008 INF  1111 
000009 INF  2222 
000010 CTL  BBBB 
000011 INF  1111 
000012 INF  1111 


Output file:
Code:
000001 HDR  1234  AAAA   
000002 INF  1111  AAAA   
000003 INF  2222  AAAA   
000004 CTL  AAAA  AAAA   
000005 INF  1111  AAAA   
000006 HDR  0034  BBBB   
000007 INF  1111  BBBB   
000008 INF  1111  BBBB   
000009 INF  2222  BBBB   
000010 CTL  BBBB  BBBB   
000011 INF  1111  BBBB   
000012 INF  1111  BBBB   


File is FB 80 . Is it possible by sort/icetool? Thanks.
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri May 11, 2012 6:11 am    Post subject:
Reply with quote

Does 'HDR' start in position 1 or in position 8 (are the sequence numbers really in the input file)?

Is there only one CTL record per group?
Back to top
View user's profile Send private message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Fri May 11, 2012 3:47 pm    Post subject:
Reply with quote

Hi Frank, HDR is in position 1, CTL is only one per group, groups may be more than 100, there is no numering in the file, it is from Edit panel
Back to top
View user's profile Send private message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Fri May 11, 2012 5:21 pm    Post subject:
Reply with quote

Actuaally I've tried to use this:
Code:
//STEP020  EXEC PGM=SORT,PARM='SIZE(MAX)'     
//SORTIN    DD *                             
HDR  1234                                     
INF  1111                                     
INF  2222                                     
CTL  AAAA                                     
INF  1111                                     
HDR  0034                                     
INF  1111                                     
INF  1111                                     
INF  2222                                     
CTL  BBBB                                     
INF  1111                                     
INF  1111                                     
//SORTOUT   DD DSN=IS.SOUT,DISP=OLD           
//BAD       DD DSN=IS.SEXT,DISP=OLD           
//FIN       DD DSN=IS.SFIN,DISP=OLD           
//SYSOUT    DD SYSOUT=*                       
//SYSIN     DD *                             
 OPTION COPY                                           
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),     
 PUSH=(60:ID=4))                                       
 OUTFIL FNAMES=BAD,INCLUDE=(1,3,CH,EQ,C'CTL')           
 JOINKEYS F1=SORTOUT,FIELDS=(60,4,A)                   
 JOINKEYS F2=BAD,FIELDS=(60,4,A)                       
 REFORMAT FIELDS=(F1:1,80,F2:1,80)                     
 OUTFIL FNAMES=FIN,BUILD=(1,10,X,86,4,80:X)             
//                                                     

but looks like the code :
Code:

OPTION COPY                                                   
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),             
PUSH=(60:ID=4))                                               
OUTFIL FNAMES=BAD,INCLUDE=(1,3,CH,EQ,C'CTL')                   

was not executed. If code above is in separate step it run ok
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7230

PostPosted: Fri May 11, 2012 5:48 pm    Post subject: Reply to: Change group of records from control record
Reply with quote

Yes, you can't do it exactly like that. The INREC etc would operate after the JOIN and you can't create the file for the join like that.

What you need is JNFnCNTL datasets for additional control cards, one for each dataset:

//JNF1CNTL DD *
//JNF2CNTL DD *

You can then do a GROUP for each file (you specify, in this type of case, your dataset name on each input to the join) and establish an ID which you will match on.

In one JNF1CNTL add (OVERLAY) a number to your "record" when you identify your control record. BUILD just the data you want to add, the ID and the "1" and SUM on the ID. Out of this CNTL you'll get all IDs with data if present and either 0 or 1.

On the other CNTL just output your record with the ID. This CNTL you don't need to let do the SORT, so put SORTED,NOSEQCK (check spelling of last) on the JOINKEYS. Overlay the ID at the end (if fixed records).

Do the join on the IDs.

REFORMAT to include all of the whole file and the data and 0/1 from the other file.

Interrogate the 0/1, update current record, if a 1, use the data, else don't.

Should be about there if you want a hack at it.
Back to top
View user's profile Send private message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Fri May 11, 2012 6:02 pm    Post subject:
Reply with quote

wow... looks complicated for me ... maybe I will stay with 2 steps. Thanks
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7230

PostPosted: Fri May 11, 2012 6:08 pm    Post subject: Reply to: Change group of records from control record
Reply with quote

It isn't complicated and it won't look that way, really it won't :-)

Search the DFSORT forum for JOINKEYS by user Skolusu, you'll find examples of the "matching a file to itself" and see what they look like.

If you just sit around anyway, you may get a solution later, of course.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7230

PostPosted: Fri May 11, 2012 6:54 pm    Post subject: Reply to: Change group of records from control record
Reply with quote

You could look at this.

The requirement was more complex than yours.
Back to top
View user's profile Send private message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Fri May 11, 2012 7:14 pm    Post subject:
Reply with quote

Thank you
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri May 11, 2012 9:42 pm    Post subject: Reply to: Change group of records from control record
Reply with quote

anatol,

It isn't that complicated. Assuming you ALWAYS have 1 and ONLY CTL record per group , the following DFSORT JCL will give you the desired results. The trick here is to use the same file twice and from the second file pick only the CTL records and attach a seqnum which will be matched with the GROUP ID from file 1. Since we are building the match key , we know it is sorted so you can join the records as if you are copying.

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//INA      DD *                                                   
HDR  1234                                                         
INF  1111                                                         
INF  2222                                                         
CTL  AAAA                                                         
INF  1111                                                         
HDR  0034                                                         
INF  1111                                                         
INF  1111                                                         
INF  2222                                                         
CTL  BBBB                                                         
INF  1111                                                         
INF  1111                                                         
//INB      DD *                                                   
HDR  1234                                                         
INF  1111                                                         
INF  2222                                                         
CTL  AAAA
INF  1111                                                         
HDR  0034                                                         
INF  1111                                                         
INF  1111                                                         
INF  2222                                                         
CTL  BBBB                                                         
INF  1111                                                         
INF  1111                                                         
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  OPTION COPY                                                     
  JOINKEYS F1=INA,FIELDS=(81,8,A),SORTED,NOSEQCK                   
  JOINKEYS F2=INB,FIELDS=(81,8,A),SORTED,NOSEQCK                   
  REFORMAT FIELDS=(F1:1,10,F2:6,4,F1:15,66)                       
//*
//JNF1CNTL DD *                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(81:ID=8))
//*
//JNF2CNTL DD *                                                   
  INCLUDE COND=(1,3,CH,EQ,C'CTL')                                 
  INREC OVERLAY=(81:SEQNUM,8,ZD)   
//*
Back to top
View user's profile Send private message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Fri May 11, 2012 9:56 pm    Post subject:
Reply with quote

Thank you... great trick
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 update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 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 abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


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