|
View previous topic :: View next topic
|
| Author |
Message |
raju.mopidevi
New User

Joined: 18 Sep 2011 Posts: 12 Location: India
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
raju.mopidevi
New User

Joined: 18 Sep 2011 Posts: 12 Location: India
|
|
|
|
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.  |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 . . .
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 |
|
 |
raju.mopidevi
New User

Joined: 18 Sep 2011 Posts: 12 Location: India
|
|
|
|
| Quote: |
| why you could not be bothered to post this originally |
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
raju.mopidevi
New User

Joined: 18 Sep 2011 Posts: 12 Location: India
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Code: |
| INCLUDE COND=(1,4,SS,EQ,'REC2,REC4') |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
ramsri
Active User

Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
As per experts advice and with my limited knowledge of SORT
| 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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|