Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
copy only X number of records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: copy only X number of records
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Mon Oct 13, 2008 2:26 pm    Post subject:
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    Post subject: Reply to: copy only X number of records
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    Post subject: Reply to: copy only X number of records
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 Moderator


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

PostPosted: Mon Oct 13, 2008 9:00 pm    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Mon Oct 13, 2008 9:04 pm    Post subject:
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    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 XMITIP sends it out. Can it copy on l... Rommel Dayon Rustia IBM Tools 0 Tue Sep 05, 2017 10:16 am
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 21 Sun Aug 27, 2017 10:35 pm
No new posts Profile changed to NUMBER ON STD (fro... Martylin TSO/ISPF 1 Thu Aug 03, 2017 9:14 am
No new posts Unable to copy data from spool in a d... srikant314 JCL & VSAM 8 Fri Jul 28, 2017 9:10 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us