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
 

 

Copy sequence number to all records

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

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Sun Apr 12, 2009 11:26 pm    Post subject: Copy sequence number to all records
Reply with quote

Hi All,
I want to copy sequence number from header(01) record to all the detail line records(05)
Also i want to omit header and trailer in output..

Code:

0100001           
05CRPICRP01ABC LTD.
05CRPICRP02XYZ LTD.
05CRPUCRP01DEF LTD.
05CRPDCRP01DEF LTD.
05CRPICRP03ABC LTD.
05CRPICRP02XXX LTD.
05CRPUCRP03LLLLLLL.
0900000007


For above input output should be...

Code:

0000105CRPICRP01ABC LTD.
0000105CRPICRP02XYZ LTD.
0000105CRPUCRP01DEF LTD.
0000105CRPDCRP01DEF LTD.
0000105CRPICRP03ABC LTD.
0000105CRPICRP02XXX LTD.
0000105CRPUCRP03LLLLLLL.


Can it be done using DFSORT?
Back to top
View user's profile Send private message

nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Mon Apr 13, 2009 10:42 am    Post subject:
Reply with quote

Hi Sambhaji,

Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80.
Code:
//S1   EXEC  PGM=ICETOOL                                       
//TOOLMSG   DD  SYSOUT=*                                       
//DFSMSG    DD  SYSOUT=*                                       
//IN1 DD *                                                     
0100001                                                       
05CRPICRP01ABC LTD.                                           
05CRPICRP02XYZ LTD.                                           
05CRPUCRP01DEF LTD.                                           
05CRPDCRP01DEF LTD.                                           
05CRPICRP03ABC LTD.                                           
05CRPICRP02XXX LTD.                                           
05CRPUCRP03LLLLLLL.                                           
0900000007                                                     
/*                                                             
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS) 
//OUT DD SYSOUT=*                                             
//TOOLIN DD *                                                 
COPY FROM(IN1) TO(T1) USING(CTL1)                             
SPLICE FROM(T1) TO(OUT) ON(81,1,CH) KEEPNODUPS -     
      WITHALL WITH(1,83) USING(CTL2)                 
/*                                                   
//CTL1CNTL DD *                                     
  OUTFIL FNAMES=T1,IFTHEN=(WHEN=INIT,               
        BUILD=(1,80,81:C'1',82:C'22',84:5X)),       
                   IFTHEN=(WHEN=(1,2,CH,EQ,C'01'),   
        BUILD=(1,80,81:C'1',82:C'11',84:3,5)),       
                   IFTHEN=(WHEN=(1,2,CH,EQ,C'09'),   
        BUILD=(1,80))                               
/*                                                   
//CTL2CNTL DD *                                     
  OUTFIL FNAMES=OUT,INCLUDE=(82,2,CH,EQ,C'22'),     
             BUILD=(1:84,5,6:1,75)                   
/*

Output:
Code:
0000105CRPICRP01ABC LTD.
0000105CRPICRP02XYZ LTD.
0000105CRPUCRP01DEF LTD.
0000105CRPDCRP01DEF LTD.
0000105CRPICRP03ABC LTD.
0000105CRPICRP02XXX LTD.
0000105CRPUCRP03LLLLLLL.

Hope this helps you.
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: Mon Apr 13, 2009 9:36 pm    Post subject:
Reply with quote

Sambhaji,

Nelson's job is not a good solution. It does NOT require two passes to do this.

You can use a much simpler one pass DFSORT job like the following to do what you asked for:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
0100001
05CRPICRP01ABC LTD.
05CRPICRP02XYZ LTD.
05CRPUCRP01DEF LTD.
05CRPDCRP01DEF LTD.
05CRPICRP03ABC LTD.
05CRPICRP02XXX LTD.
05CRPUCRP03LLLLLLL.
0900000007
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
   OPTION COPY
   INREC IFTHEN=(WHEN=INIT,BUILD=(6:1,75)),
     IFTHEN=(WHEN=GROUP,BEGIN=(6,2,CH,EQ,C'01'),
       PUSH=(1:8,5))
   OUTFIL INCLUDE=(6,2,CH,EQ,C'05')
/*
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Apr 13, 2009 10:07 pm    Post subject:
Reply with quote

Thanks Frank...

One more good news is now WHEN=GROUP is working at my shop... [icon_smile.gif]... .Which couple of months before was not..
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: Mon Apr 13, 2009 10:41 pm    Post subject:
Reply with quote

Well, WHEN=GROUP has been available for DFSORT since July, 2008 so it's good that your shop is finally catching up. icon_biggrin.gif
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Apr 13, 2009 11:32 pm    Post subject:
Reply with quote

Quote:
so it's good that your shop is finally catching up.


Yeah...


Now I can revisit all the sort jcls and check if I can use powerful funtionalities like FINDREP and WHEN=GROUP...
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Wed Apr 15, 2009 9:43 am    Post subject:
Reply with quote

In my shop we don't have WHEN=GROUP funtionalities yet. So only i used the prior version with 2 passes.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Apr 15, 2009 7:43 pm    Post subject: Reply to: Copy sequence number to all records
Reply with quote

nelson.pandian wrote:
In my shop we don't have WHEN=GROUP funtionalities yet. So only i used the prior version with 2 passes.


Not really. You don't need 2 passes at all. You can do it in one step using splice with a copy as the records are already in order. Here is an example.

Code:

//STEP0100 EXEC PGM=ICETOOL                               
//TOOLMSG  DD SYSOUT=*                                     
//DFSMSG   DD SYSOUT=*                                     
//IN  DD *                                                 
0100001                                                   
05CRPICRP01ABC LTD.                                       
05CRPICRP02XYZ LTD.                                       
05CRPUCRP01DEF LTD.                                       
05CRPDCRP01DEF LTD.                                       
05CRPICRP03ABC LTD.                                       
05CRPICRP02XXX LTD.                                       
05CRPUCRP03LLLLLLL.                                       
0900000007                                                 
//OUT      DD SYSOUT=*
//TOOLIN   DD *                                           
  SPLICE FROM(IN) TO(OUT) ON(81,1,CH) WITH(6,75) -         
  WITHALL USING(CTL1)                                     
//CTL1CNTL DD *                                           
  SORT FIELDS=COPY                                         
  OMIT COND=(1,2,CH,EQ,C'09')                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(6:1,75,C'1')),         
  IFTHEN=(WHEN=(6,2,CH,EQ,C'01'),OVERLAY=(1:8,5))         
  OUTFIL FNAMES=OUT,BUILD=(1,80)                           
/*


If you really want a 2 pass solution then you don't need to copy the entire file as you are only interested in the header record. Create a symbol by just copying the first record and then use it in the second step which is much more efficient.

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                             
0100001                                                     
05CRPICRP01ABC LTD.                                         
05CRPICRP02XYZ LTD.                                         
05CRPUCRP01DEF LTD.                                         
05CRPDCRP01DEF LTD.                                         
05CRPICRP03ABC LTD.                                         
05CRPICRP02XXX LTD.                                         
05CRPUCRP03LLLLLLL.                                         
0900000007                                                 
//SORTOUT  DD DSN=&&C1,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE) 
//SYSIN    DD    *                                         
  OPTION COPY,STOPAFT=1                                     
  OUTREC BUILD=(C'MYHDR,C''',3,5,C'''',80:X)               
/*                                                         
//STEP0200 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SYMNAMES DD DSN=&&C1,DISP=(OLD,PASS)                     
//SORTIN   DD *                                             
0100001                                                     
05CRPICRP01ABC LTD.                                         
05CRPICRP02XYZ LTD.                                         
05CRPUCRP01DEF LTD.                                         
05CRPDCRP01DEF LTD.                                         
05CRPICRP03ABC LTD.                                         
05CRPICRP02XXX LTD.                                         
05CRPUCRP03LLLLLLL.                                         
0900000007                                                 
//SORTOUT  DD SYSOUT=*
//SYSIN    DD    *                                         
  OMIT COND=(1,2,SS,EQ,C'01,09')                           
  SORT FIELDS=COPY                                         
  INREC BUILD=(MYHDR,1,75)                                 
/*                                                         
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: Wed Apr 15, 2009 9:02 pm    Post subject:
Reply with quote

Quote:
In my shop we don't have WHEN=GROUP funtionalities yet. So only i used the prior version with 2 passes.


Given that you don't have the latest PTF and we have two DFSORT developers here to provide efficient DFSORT/ICETOOL solutions, perhaps it would be better if you didn't post inefficient solutions at all.
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 Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm
No new posts copy SEQ to PDS and create stats steve-myers JCL & VSAM 5 Thu Apr 27, 2017 1:15 am
No new posts Copy load modules and alias vasanthz IBM Tools 5 Thu Apr 20, 2017 6:31 am
No new posts Edit large number of datasets (QSAM) zh_lad TSO/ISPF 3 Tue Apr 04, 2017 6:08 pm


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