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

Add control records using ICETOOL


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Captain Paralytic
Warnings : 1

New User


Joined: 21 Apr 2010
Posts: 40
Location: UK

PostPosted: Mon Jul 05, 2010 8:02 pm
Reply with quote

I have an input file that looks like:
A1
A3
A4
B1
B2
B7
C6

As an output I want:
dA1
dA3
dA4
cA0
dB1
dB2
dB7
cB0
dC6
cC0

Effectively, all the original records become Detail records and at the end of each group, I add a Control record.

Now, I have figured out how I can do this using a SORT, but since the file is already sorted, I'm sure that there must be a "cheaper" way to just add these records in a single pass.
I am using SELECT with LASTDUP to write the extra Control record and DISCARD(savedd) is keeping the rest of the records, but I have only succeeded in getting the DISCARDs added on at the end of the file.

Any ideas much appreciated.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Jul 05, 2010 8:14 pm
Reply with quote

Please post your Sort JCL and control statements.
If it is already sorted, don't SORT, just COPY.
Back to top
View user's profile Send private message
Captain Paralytic
Warnings : 1

New User


Joined: 21 Apr 2010
Posts: 40
Location: UK

PostPosted: Mon Jul 05, 2010 9:05 pm
Reply with quote

OK, here it is. I just realised that it doesn't handle the C6 record correctly either, since that it not a duplicate of anything!

Code:
//S3 EXEC PGM=ICETOOL                                         
//TOOLMSG DD SYSOUT=*                                         
//DFSMSG  DD SYSOUT=*                                         
//IND1    DD *                                               
A1                                                           
A3                                                           
A4                                                           
B1                                                           
B2                                                           
B7                                                           
C6                                                           
//T1      DD DSN=&&F1,UNIT=SYSDA,SPACE=(CYL,(5,5)),           
//**   USE MOD FOR F1                                         
//           DISP=(MOD,PASS)                                 
//T2      DD DSN=&&TX,UNIT=SYSDA,SPACE=(CYL,(5,5)),           
//**   USE MOD FOR T1                                         
//           DISP=(MOD,PASS)                                 
//OUTD    DD SYSOUT=*  Driver                                 
//TOOLIN DD *                                                 
  SELECT FROM(IND1) TO(OUTD) ON(1,1,CH) LASTDUP USING(CTL1) -
         DISCARD(T2)                                         
  COPY FROM(T2) TO(OUTD) USING(CTL2)                         
/*                                                           
//CTL1CNTL DD *                                               
  INCLUDE COND=(3,1,CH,EQ,C' ')                               
  OUTFIL FNAMES=OUTD,BUILD=(C'd',1,2,/,C'c',1,1,C'0')         
/*                                                           
//CTL2CNTL DD *                                               
  INCLUDE COND=(3,1,CH,EQ,C' ')                               
  OUTFIL FNAMES=OUTD,BUILD=(C'd',1,2)                         
/*                                                           
[/code]
Back to top
View user's profile Send private message
Captain Paralytic
Warnings : 1

New User


Joined: 21 Apr 2010
Posts: 40
Location: UK

PostPosted: Mon Jul 05, 2010 9:20 pm
Reply with quote

I've made it handle the C6 case now, but the output records are still all out of order.

Code:
//S3 EXEC PGM=ICETOOL                                       
//TOOLMSG DD SYSOUT=*                                       
//DFSMSG  DD SYSOUT=*                                       
//IND1    DD *                                               
A1                                                           
A3                                                           
A4                                                           
B1                                                           
B2                                                           
B7                                                           
C6                                                           
//T1      DD DSN=&&F1,UNIT=SYSDA,SPACE=(CYL,(5,5)),         
//**   USE MOD FOR F1                                       
//           DISP=(MOD,PASS)                                 
//T2      DD DSN=&&TX,UNIT=SYSDA,SPACE=(CYL,(5,5)),         
//**   USE MOD FOR T1                                       
//           DISP=(MOD,PASS)                                 
//OUTD    DD SYSOUT=*  Driver                               
//TOOLIN DD *                                               
  SELECT FROM(IND1) TO(OUTD) ON(1,1,CH) NODUPS USING(CTL1) -
         DISCARD(T1)                                         
  SELECT FROM(T1) TO(OUTD) ON(1,1,CH) LASTDUP USING(CTL1) - 
         DISCARD(T2)                                         
  COPY FROM(T2) TO(OUTD) USING(CTL2)                         
/*                                                           
//CTL1CNTL DD *                                             
  INCLUDE COND=(3,1,CH,EQ,C' ')                             
  OUTFIL FNAMES=OUTD,BUILD=(C'd',1,2,/,C'c',1,1,C'0')       
/*                                                           
//CTL2CNTL DD *                                             
  INCLUDE COND=(3,1,CH,EQ,C' ')                             
  OUTFIL FNAMES=OUTD,BUILD=(C'd',1,2)                       
/*                                                           
[/code]
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Mon Jul 05, 2010 10:07 pm
Reply with quote

Try this...

Code:
//STEP01   EXEC PGM=SORT                   
//SYSOUT   DD SYSOUT=*                     
//SORTIN   DD *                           
A1                                         
A3                                         
A4                                         
B1                                         
B2                                         
B7                                         
C6                                         
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *                           
  INREC BUILD=(1:C'D',2:1,2)               
  OPTION COPY                             
  OUTFIL REMOVECC,                         
  SECTIONS=(2,1,                           
            TRAILER3=('C',2,1,'0'))       
//*                                       


OUTPUT

Code:
DA1       
DA3       
DA4       
CA0       
DB1       
DB2       
DB7       
CB0       
DC6       
CC0       


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: Tue Jul 06, 2010 2:48 am
Reply with quote

You don't need INREC and OUTFIL - you can do it all with OUTFIL like this:

Code:

  OPTION COPY                   
  OUTFIL REMOVECC,             
    BUILD=(C'd',1,2),           
    SECTIONS=(1,1,             
      TRAILER3=('c',1,1,'0'))   
Back to top
View user's profile Send private message
Captain Paralytic
Warnings : 1

New User


Joined: 21 Apr 2010
Posts: 40
Location: UK

PostPosted: Tue Jul 06, 2010 2:50 pm
Reply with quote

Frank you are a star (but I guess you already know that).

Many thanks.
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Format data from multiple records usi... SYNCSORT 4
No new posts Sort SMF records? SYNCSORT 6
No new posts To Sort detail records in a file with... SYNCSORT 5
No new posts Identify and write records containing... SYNCSORT 11
No new posts Filter records where condition is in ... SYNCSORT 6
Search our Forums:


Back to Top