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

Repeat seven times input file in one step


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

New User


Joined: 27 Nov 2007
Posts: 7
Location: Madrid

PostPosted: Thu Oct 30, 2008 7:21 pm
Reply with quote

Hi,

I want to repeat all input records seven times into the output file through "one only" SORT.

Thanks.
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Thu Oct 30, 2008 7:55 pm
Reply with quote

Probably You need to use
OUTFIL REPEAT=7

But to get precise answer
you need to post sample input and desired output icon_smile.gif
Back to top
View user's profile Send private message
Guirao

New User


Joined: 27 Nov 2007
Posts: 7
Location: Madrid

PostPosted: Thu Oct 30, 2008 8:21 pm
Reply with quote

This is my SORT:

Quote:
//SORT0001 EXEC PGM=SORT
//SORTIN DD DSN=XE04183.INICIO,DISP=SHR
//SORTOUT DD DSN=XE04183.INICIO.SALIDA,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(1,5),RLSE)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REPEAT=7


and this is my input file:

Quote:
....REC 1
....REC 2


... and the result:

Quote:
....REC 1
....REC 1
....REC 1
....REC 1
....REC 1
....REC 1
....REC 1
....REC 2
....REC 2
....REC 2
....REC 2
....REC 2
....REC 2
....REC 2


But I want to repeat the block of the input file, so i wish is that following:

Quote:
....REC 1
....REC 2
....REC 1
....REC 2
....REC 1
....REC 2
....REC 1
....REC 2
....REC 1
....REC 2
....REC 1
....REC 2
....REC 1
....REC 2


Thanks[/quote]
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Thu Oct 30, 2008 8:40 pm
Reply with quote

Change your code as below
Code:

//SORT0001 EXEC PGM=SORT
//SORTIN DD DSN=XE04183.INICIO,DISP=SHR
//       DD DSN=XE04183.INICIO,DISP=SHR
//       DD DSN=XE04183.INICIO,DISP=SHR
//       DD DSN=XE04183.INICIO,DISP=SHR
//       DD DSN=XE04183.INICIO,DISP=SHR
//       DD DSN=XE04183.INICIO,DISP=SHR
//       DD DSN=XE04183.INICIO,DISP=SHR
//SORTOUT DD DSN=XE04183.INICIO.SALIDA,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(1,5),RLSE)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
/*
Back to top
View user's profile Send private message
Guirao

New User


Joined: 27 Nov 2007
Posts: 7
Location: Madrid

PostPosted: Thu Oct 30, 2008 8:49 pm
Reply with quote

OK, the results where exactly what i want.

Thanks a lot.
Regards.
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Thu Oct 30, 2008 8:52 pm
Reply with quote

Quote:
OK, the results where exactly what i want.

Thanks a lot.

U R Welcome icon_smile.gif
Back to top
View user's profile Send private message
cybertaurean

New User


Joined: 22 Dec 2008
Posts: 87
Location: US

PostPosted: Thu Sep 29, 2011 4:06 pm
Reply with quote

@Escapa... Can anything be done through sort if the # of required repetitions (in the fashion mentioned above) is huge... say 10000 times.

I believe dataset concatenation wouldn't work in such a case. Any other option to get it done using SORT?

Regards,
C.T.
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: Thu Sep 29, 2011 4:54 pm
Reply with quote

'course you can.

Use the first method to replicate the individual records 10000. Sequence number each individual record starting from 1 until the next record that gets replicated. Sort on the sequence number, with EQUALS, strip off the sequence number. You should have now a file which is replicated in its' entirety 10,000 times.

Don't have the code for it (I think you were just curious :-) ). Don't know if it can be done in one step. Don't see why it can't be done. Can't imagine yet why anyone would want to.

Frank or Kolusu will probably say I don't need to over-complicate, and do it in two lines :-) They, and the product, are so good that nothing would surprise me.
Back to top
View user's profile Send private message
cybertaurean

New User


Joined: 22 Dec 2008
Posts: 87
Location: US

PostPosted: Thu Sep 29, 2011 10:06 pm
Reply with quote

@bill: awesome! i was thinking on lines of what u felt kolusu or frank might talk about... i.e. without having to use a sequence number icon_smile.gif

thanks a lot!!! icon_biggrin.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Sep 29, 2011 10:11 pm
Reply with quote

cybertaurean wrote:
@Escapa... Can anything be done through sort if the # of required repetitions (in the fashion mentioned above) is huge... say 10000 times.



cybertaurean,

As bill mentioned here it CAN be done. And bill yes it is indeed easy icon_wink.gif ,however there is a catch.


Case 1
If Number of input records >= repetition factor then 1 pass of data with JOINKEYS

case 2

If Number of input records < repetition factor then you need 2 passes of data.


Case 1 solution

Joinkeys can be used to do Many to Many match. And we will use that feature to generate the data. The trick here is to use the same dataset for both JNF1 and JNF2 and then match on a key we add at the end of the record.

Code:

//STEP0100 EXEC PGM=SORT,REGION=0M         
//SYSOUT   DD SYSOUT=*                     
//INA      DD *                             
REC01                                       
REC02                                       
REC03                                       
REC04                                       
REC05                                       
REC06                                       
REC07                                       
REC08                                       
REC08                                       
REC10                                       
//INB      DD *                                   
REC01                                             
REC02                                             
REC03                                             
REC04                                             
REC05                                             
REC06                                             
REC07                                             
REC08                                             
REC08                                             
REC10                                             
//SORTOUT  DD SYSOUT=*                             
//SYSIN    DD *                                   
  JOINKEYS F1=INA,FIELDS=(81,1,A),SORTED,NOSEQCK   
  JOINKEYS F2=INB,FIELDS=(01,1,A),SORTED,NOSEQCK   
  REFORMAT FIELDS=(F1:1,80,F2:2,8)                 
  INCLUDE COND=(81,8,ZD,LE,7)      <<== CODE REPEAT FACTOR HERE
  SORT FIELDS=(81,8,CH,A),EQUALS                   
  OUTREC BUILD=(1,80)                             
//*                                               
//JNF1CNTL DD *                                   
  INREC OVERLAY=(81:X)                             
//*                                               
//JNF2CNTL DD *                                   
  INREC BUILD=(X,SEQNUM,8,ZD)                     
//*



Case 2 solution:

Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                                 
REC01                                                           
REC02                                                           
REC03                                                           
//SORTOUT  DD DSN=&&IN,DISP=(,PASS),SPACE=(CYL,(10,10),RLSE)   
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                             
  OUTREC OVERLAY=(81:SEQNUM,8,ZD)                               
  OUTFIL REPEAT=7,                <<== CODE REPEAT FACTOR HERE 
  IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(81,8)))   
//*                                                             
//STEP0200 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DSN=&&IN,DISP=SHR                                 
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  SORT FIELDS=(81,8,CH,A),EQUALS                               
  OUTREC BUILD=(1,80)                                           
//*
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 Sep 30, 2011 6:04 am
Reply with quote

Very nice, Kolusu, very nice.

So, when requiring multiple duplications of a dataset:


  • If it needs only be "logical", concatenate (up to max allowed) into desired program


  • If it needs to be "physical" (on one dataset)
    concatenate with sort, up to max allowed
  • Else, Case 1 when records >= repetition factor
  • Otherwise, Case 2

If it is a close call for Case 1, Case 2 will always work, but with two passes of the data.
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 IGYPG3178-I when compiling a pgm read... COBOL Programming 6
No new posts FileAid move data from two files to o... Compuware & Other Tools 5
No new posts Sorting date into YYYYMMDD, and creat... DFSORT/ICETOOL 13
No new posts To Sort detail records in a file with... SYNCSORT 5
No new posts To Populate Trailer cnt in the file w... SYNCSORT 1
Search our Forums:


Back to Top