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

Change group of records from control record


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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Fri May 11, 2012 4:21 am
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 Developer


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

PostPosted: Fri May 11, 2012 6:11 am
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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Fri May 11, 2012 3:47 pm
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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Fri May 11, 2012 5:21 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri May 11, 2012 5:48 pm
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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Fri May 11, 2012 6:02 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri May 11, 2012 6:08 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri May 11, 2012 6:54 pm
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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Fri May 11, 2012 7:14 pm
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
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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Fri May 11, 2012 9:56 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top