View previous topic :: View next topic
|
Author |
Message |
sivasree03
New User
Joined: 12 Sep 2008 Posts: 8 Location: chennai
|
|
|
|
Hi all,
I have a requirement to copy X number of records from one file to another file. This X is defined in one PARM file.
Do we have any options in SORT to read this PARM file and copy X number of records to another file thru a single SORT step? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Hi,
There may be efficient solutions than this but here is the one which will help you.
Code: |
//STEP050 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
1
2
3
4
5
6
7
8
/*
//PARMFILE DD *
05
/*
//TMP1CNTL DD DSN=&&TEMP,DISP=(MOD,PASS),SPACE=(CYL,(1,10),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(PARMFILE) TO(TMP1CNTL) USING(CTL1)
COPY FROM(IN) TO(OUT) USING(TMP1)
/*
//CTL1CNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=TMP1CNTL,NODETAIL,REMOVECC,
HEADER1=(3:'SORT FIELDS=COPY',/,
3:'OUTFIL FNAMES=OUT,ENDREC=',1,2)
/*
|
|
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
You could also consider the use of IDCAMS REPRO to do this. |
|
Back to top |
|
|
sivasree03
New User
Joined: 12 Sep 2008 Posts: 8 Location: chennai
|
|
|
|
Hi,
Thanks for your quick reply. I can not define the X value in JCL or in PARM Member.
This value is not constant, we may need to change it on requirement basis. We have to read this value from a SEQ file and copy these many number of records from input file to output file. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
gorman,
You can pass symbolics to SORT like shown below. Define a symbolic named pickrec and you can override it in jcl with the number of records you want
Code: |
//MYPROC PROC PICKREC='10'
//STEP1 EXEC PGM=ICEMAN,PARM='STOPAFT=&PICKREC'
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=some dataset,
// DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD DSN=sort.control.card dataset,
// DISP=SHR
//*
// PEND
//STEP0100 EXEC MYPROC,PICKREC='50'
|
|
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
There may be efficient solutions than this but here is the one which will help you. |
Yes, there are more efficient solutions. Why do you think posting an overly complex and inefficient solution is a way to help someone? You're not really helping people by continually doing that. You're just misleading them.
If the OP can use a symbol instead of a parmfile, then Kolusu's use of a symbolic for STOPAFT is best. And if the OP needs to use a parmfile, this DFSORT/ICETOOL job is better than your solution. STOPAFT is more efficient than ENDREC.
I assumed the parmfile has a 2-digit value for the number of records (e.g. 05), but the job can be changed appropriately for more digits).
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//PARMFILE DD DSN=... seq file with nn for number of records
//IN DD *
RECORD 01
RECORD 02
RECORD 03
RECORD 04
RECORD 05
RECORD 06
RECORD 07
RECORD 08
/*
//CTL2CNTL DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(PARMFILE) TO(CTL2CNTL) USING(CTL1)
COPY FROM(IN) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
OUTREC BUILD=(C' OPTION STOPAFT=',1,2,80:X)
/*
|
|
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Quote: |
You could also consider the use of IDCAMS REPRO to do this. |
Code: |
//IDCAMS01 EXEC PGM=IDCAMS
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//INPUT DD DSN=
//OUTPTFL DD DSN=
//SYSIN DD *
PARM MARGINS(1 72)
REPRO IFILE(INPUT) OFILE(OUTPTFL) -
COUNT (
// DD DSN=dataset with count in it
)
/*
|
|
|
Back to top |
|
|
|