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
 

 

Repeating selective records in a file

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

New User


Joined: 18 Sep 2011
Posts: 12
Location: India

PostPosted: Thu Sep 27, 2012 11:16 pm    Post subject: Repeating selective records in a file
Reply with quote

My input file is like this

Code:
REC1 Data1
REC2 Data2
REC2 Data3
REC3 Data4
REC4 Data5
REC5 Data6


Now, I have to repeat REC2 & REC4 for 5 times. Sample output will be like this

Code:
REC1 Data1
REC2 Data2
REC2 Data2
REC2 Data2
REC2 Data2
REC2 Data2
REC2 Data2
REC2 Data3
REC2 Data3
REC2 Data3
REC2 Data3
REC2 Data3
REC2 Data3
REC3 Data4
REC4 Data5
REC4 Data5
REC4 Data5
REC4 Data5
REC4 Data5
REC4 Data5
REC5 Data6


As a first step I tried to repeat REC2 for 5 times. I tried by using REPEAT keyword with INCLUDE COND

OPTION COPY
INCLUDE=(1,4,CH,EQ,'REC2')
REPEAT=5

I am able to repeat for desired number of times, but INCLUDE condition also filtering other records. So, My output file is missing other record types. (REC1, REC3,REC4,REC5). My output file is like this :

Code:
REC2 Data2
REC2 Data2
REC2 Data2
REC2 Data2
REC2 Data2
REC2 Data2
REC2 Data3
REC2 Data3
REC2 Data3
REC2 Data3
REC2 Data3
REC2 Data3


How can I repeat multiple record types ?
Back to top
View user's profile Send private message

Skolusu

Senior Member


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

PostPosted: Fri Sep 28, 2012 1:21 am    Post subject:
Reply with quote

raju.mopidevi,

Use the following DFSORT JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD *                                       
REC1 DATA1                                           
REC2 DATA2                                           
REC2 DATA3                                           
REC3 DATA4                                           
REC4 DATA5                                           
REC5 DATA6                                           
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                       
  SORT FIELDS=COPY                                   
  OUTFIL IFTHEN=(WHEN=(1,4,SS,EQ,C'REC2,REC4'),       
  BUILD=(1,80,/,1,80,/,1,80,/,1,80,/,1,80,/,1,80))   
//*
Back to top
View user's profile Send private message
raju.mopidevi

New User


Joined: 18 Sep 2011
Posts: 12
Location: India

PostPosted: Fri Sep 28, 2012 6:58 am    Post subject:
Reply with quote

Thanks kolusu. I got the logic. But I have few problems.

1. My data file is VB.
2. 'Repeat' parameter is big. Say for example 20000

For the first one, I know that, I have to replace the positions. But, the second one is a big concern for me. I can't go for repeating BUILD statement multiple times. icon_sad.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Sep 28, 2012 8:20 am    Post subject:
Reply with quote

Hello,

Now, go back over what you originally posted and this latest "discovery" and meditate on why you could not be bothered to post this originally . . . You knew the number could be rather large.

Why should Kolusu spend more time on another solution that may be completely undone by a newer revelation . . . icon_sad.gif

Of course if you want this quickly, suggest you go ahead and write a tiny bit of code to do what you want. Then when the scope changes again, it will all be under your control.
Back to top
View user's profile Send private message
raju.mopidevi

New User


Joined: 18 Sep 2011
Posts: 12
Location: India

PostPosted: Fri Sep 28, 2012 9:43 am    Post subject:
Reply with quote

Quote:
why you could not be bothered to post this originally
icon_cry.gif

Sorry for that. I thought my code will be improved by adding few controls which allows missing records also be written in the output file. So I am completely thinking about the missing records. I didnot bother about the repeat value, as it can be easily configured in code. (i.e. I can easily change repeat parameter value to desired result).

Code:
OPTION COPY
INCLUDE=(1,4,CH,EQ,'REC2')
 OUTFIL REPEAT=5


Let me make it clear
♦ Input file -> create large file -> Generate statement of 50 MB
♦ Main objective - After processing this output file, we should be able to generate a statement of 50MB
♦ Approach - only REC2 & REC4 can increase the size of the statement. Other records can not help for increasing the size. SO there will be no use to repeat other record types.

♦ Input file -> repeat REC2 & REC4 -> create big file -> Statement of 50MB.

So, I am not sure about the repeat parameter value. It can be greater than 20000+.

Can we able to multiply the repeating string in the BUILD control ?
Like
Code:
OUTFIL IFTHEN=(WHEN=(1,4,SS,EQ,C'REC2,REC4'),       
  BUILD=(1,80,/,1,80,/,1,80,/,1,80,/,1,80,/,1,80)) 


▬▬▬▬▬▬▬▬
I can dynamically generate SYSIN for this DFSORT using REXX.
Code:
ALLOCATE FI(SYSIN) DA('<<<my sys in file>>>') SHR REUSE
EXECIO * DISKW "SYSIN" (STEM rec. FINIS"
j=1
rec.j="  SORT FIELDS = COPY"
j = j+1
rec.j="  OUTFIL IFTHEN=(WHEN=(1,4,SS,EQ,C'REC2,REC4'),"
j = j+1
rec.j ="   BUILD=(1,80,/,1,80,/,1,80,/,1,80,/,1,80,/,1,80,
do i=1 to repeat_val by 1
   rec.j="          1,80,/,1,80,/,1,80,/,1,80,/,1,80,/,1,80,"
   j=j+1
end
rec.j = "       1,80,/,1,80,/,1,80,/,1,80,/,1,80,/,1,80))"
"EXECIO "j" DISKW "SYSIN" (STEM rec. FINIS"

ADDRESS TSO
"ALLOCATE DS("MSGLOG") F(SYSOUT) NEW SPACE(50,100)",
"DSORG(PS) RECFM(F B) LRECL(80) BLKSIZE(800) "
"ALLOCATE FI(SORTIN) DA('"<<< my sort input file >>>") SHR REUSE"
ALLOCATE FI(SORTOUT) DS("<<< my sort outfile >>>>") LIKE("<<input file name>>>") "
"ADDRESS ISPEXEC "SELECT PGM(SORT) "     


But, this makes my SYSIN as a large file. Is there any smart way ? Is it possible to improve my first code ?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Sep 28, 2012 11:46 pm    Post subject:
Reply with quote

raju.mopidevi,

Please post all the detail about the requirement at once.

Woah you want to generate a SYSIN to contain 20,000 control cards with / parm? You are complicating a simple request.

Do you need the REC2 and REC4 in their original position of the input or it doesn't matter even if they are at the end of the file?
Back to top
View user's profile Send private message
raju.mopidevi

New User


Joined: 18 Sep 2011
Posts: 12
Location: India

PostPosted: Sat Sep 29, 2012 5:57 am    Post subject:
Reply with quote

kolusu,

Yes, that one complicates the problem.

Quote:
Do you need the REC2 and REC4 in their original position of the input or it doesn't matter even if they are at the end of the file?


REC2 & REC4 should be at the same position. i.e. Their repetition should be exactly below the REC2 & REC4 respectively.

My current approach.

1. Repeat REC2 & REC4 using
Code:
OPTION COPY
INCLUDE=(1,4,CH,EQ,'REC2,REC4')
 OUTFIL REPEAT=5


2. Then merge above output with the original Data set.

I will be glad if it can be done in one SORT card. I will let you know if above approach works out or not !
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Sat Sep 29, 2012 6:08 am    Post subject: Reply to: Repeating selective records in a file
Reply with quote

Code:
  INCLUDE COND=(1,4,SS,EQ,'REC2,REC4')
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Sat Sep 29, 2012 6:55 am    Post subject: Reply to: Repeating selective records in a file
Reply with quote

If you do the INCLUDE on OUTFIL with a named file, and a second OUTFIL with SAVE then in a seperate step MERGE the two.

Because the REPEAT is on OUTFIL I can't think of a way (other than the same DD on two OUTFILs, which I don't think will work) with only one pass of the data.

I can be wrong :-)

EDIT: I now notice that you say "merge with the original dataset" in your last. That would work as well, without having to write out the extra from the OUTFIL with SAVE. You could get the "exact" amount of records by coding the value of ( "desired repeated records in total" - one ) on the REPEAT= .
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Sun Sep 30, 2012 9:59 am    Post subject: Reply to: Repeating selective records in a file
Reply with quote

As per experts advice and with my limited knowledge of SORT icon_rolleyes.gif

Code:

//STEP0003 EXEC PGM=ICETOOL                     
//TOOLMSG  DD SYSOUT=*                           
//SSMSG    DD SYSOUT=*                           
//SRTOUT1  DD DSN=&&TEMP1,DISP=(MOD,PASS,DELETE) 
//SORTOF2  DD SYSOUT=*                           
//IN       DD *                                   
REC1 DATA1                                       
REC2 DATA2                                       
REC2 DATA3                                       
REC3 DATA4                                       
REC4 DATA5                                       
REC5 DATA6                                       
//TOOLIN   DD *                                   
  COPY FROM(IN) TO(SRTOUT1)                       
  COPY FROM(IN) TO(SRTOUT1) USING(RAM1)           
  SORT FROM(SRTOUT1) TO(SORTOF2) USING(RAM2)     
//RAM1CNTL DD *                                   
  OUTFIL INCLUDE=(1,4,SS,EQ,C'REC2,REC4'),REPEAT=5
//RAM2CNTL DD *                                   
  SORT FIELDS=(1,4,CH,A)                         


HTH.

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Sun Sep 30, 2012 2:58 pm    Post subject: Reply to: Repeating selective records in a file
Reply with quote

Ramsri,

Nice to see you helping out.

However,

One COPY, REPEAT= being (value-desired minus one)
Then MERGE new file with original

Other than loosing flexibility, I'm never sure what the point is of using ICETOOL for this type of thing. "One step" "two steps" not enough difference to warrant making it more complex, to my mihd.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Oct 02, 2012 9:56 pm    Post subject: Reply to: Repeating selective records in a file
Reply with quote

raju.mopidevi,

The ideal solution would be a 2 step solution as shown below

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=Your Input VB file,DISP=SHR
//RPFILE   DD DSN=&&V1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//OTHER    DD DSN=&&V2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  INREC BUILD=(1,4,SEQNUM,8,ZD,5)                         
  OUTFIL FNAMES=RPFILE,REPEAT=20000,                       
  INCLUDE=(13,4,SS,EQ,C'REC2,REC4')                       
  OUTFIL FNAMES=OTHER,SAVE                                 
//*                                                       
//STEP0200 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN01 DD DSN=&&V1,DISP=SHR                           
//SORTIN02 DD DSN=&&V2,DISP=SHR                           
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                           
  MERGE FIELDS=(5,8,CH,A)                                 
  OUTREC BUILD=(1,4,13)                                   
//*
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


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