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

copy only X number of records


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

New User


Joined: 12 Sep 2008
Posts: 8
Location: chennai

PostPosted: Mon Oct 13, 2008 12:29 pm
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Mon Oct 13, 2008 2:20 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Oct 13, 2008 2:26 pm
Reply with quote

You could also consider the use of IDCAMS REPRO to do this.
Back to top
View user's profile Send private message
sivasree03

New User


Joined: 12 Sep 2008
Posts: 8
Location: chennai

PostPosted: Mon Oct 13, 2008 6:25 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Oct 13, 2008 9:00 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Oct 13, 2008 9:00 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Oct 13, 2008 9:04 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
Search our Forums:

Back to Top