Page 1 of 2

JCL to copy first 50 records

PostPosted: Tue Dec 07, 2010 10:10 pm
by anubhav.1982
Hi

I need a JCL that copies the first 50 records from source file to destination file.

Thnaks for your help

Anubhav

Re: JCL to copy first 50 records

PostPosted: Tue Dec 07, 2010 10:14 pm
by Robert Sample
Good luck with that -- since JCL does nothing but execute programs, you will have to wait a LONG, LONG, LONG time before the JCL will copy records.

Now, if you had a need to use IDCAMS or SORT to copy records within a job -- that is simplicity and you could read the appropriate manuals yourself to do so.

Re: JCL to copy first 50 records

PostPosted: Tue Dec 07, 2010 10:19 pm
by anubhav.1982
Hey Robert

Copying the records from one file to another is real quick in JCL and I have been doing that for a while that.
I only needed selective copying.


I tried IDCALMS/sort but it does not work.

thnks
Anubhav

Re: JCL to copy first 50 records

PostPosted: Tue Dec 07, 2010 10:39 pm
by Frank Yaeger
You can use a DFSORT job like the following:

//S1 EXEC PGM=SORT                                               
//SYSOUT DD SYSOUT=*                                             
//SORTIN DD DSN=...  input file                                                   
//SORTOUT DD DSN=...  output file 
//SYSIN DD *                                                     
  OPTION COPY,STOPAFT=50                                                   


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080

Re: JCL to copy first 50 records

PostPosted: Tue Dec 07, 2010 10:40 pm
by Frank Yaeger
I tried IDCALMS/sort but it does not work.


This kind of statement is pretty useless as we don't know what you tried exactly or what error you got. In the future, give details so people can help you.

Re: JCL to copy first 50 records

PostPosted: Tue Dec 07, 2010 10:46 pm
by anubhav.1982
tHE jcl GAVE AN ERROR

WER224A SORTIN NOT DEFINED

Re: JCL to copy first 50 records

PostPosted: Tue Dec 07, 2010 10:55 pm
by anubhav.1982
I used the fllowing JCl

//CP1 JOB (SB9IC-FSSGEN,PLZ2),'ALMSPL - COPY',
// MSGCLASS=A
/*PROFILE CPU=(5,00),TAPE=2
/*ROUTE PRINT SDSF
/*NOTIFY VQ103
//*
//* COPY SPL FILE
//*
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=A
//SYSUT1 DD DSN=SB900.GIPRIC.ALMFTP.DVLP.PRG.DEV.ANUBH4,DISP=SHR
//SYSUT2 DD DSN=SB900.GIPRIC.ALMFTP.DVLP.PRG.DEV.ANUBH411,
// DISP=(NEW,CATLG,DELETE),UNIT=INFOREAL,
// LABEL=EXPDT=60001,SPACE=(CYL,(95,30),RLSE)
//SYSIN DD *
OPTION COPY,STOPAFT=50
**************************** Bottom of Data ************************

Re: JCL to copy first 50 records

PostPosted: Tue Dec 07, 2010 11:07 pm
by Robert Sample
I use IDCAMS to copy records all the time:
//STEP1    EXEC PGM=IDCAMS,REGION=6M
//SYSPRINT DD   SYSOUT=*
//DD01     DD   DISP=SHR,DSN=source.data.set
//DD02     DD   DISP=SHR,DSN=target.data.set
//SYSIN    DD   *
  REPRO IFILE(DD01) OFILE(DD02) COUNT(50)
so when you said IDCAMS "did not work" -- what do you mean? Did you get a JCL error? Did you get a system abend? Did you get an IDCAMS error? Did something else happen?

You can even use the SKIP option of REPRO to get IDCAMS to start somewhere other than the first record.

Re: JCL to copy first 50 records

PostPosted: Tue Dec 07, 2010 11:08 pm
by enrico-sorichetti
the jcl You used does not follow the guidelines given by Frank!

anyway Frank Yaeger is a DFSORT Developer,
since DFSORT and SYNCSORT are competitor products, do not expect from Frank answers on SYNCOSRT

read the SYNCSORT documentation for the ddnames required/implied/used by SYNCSORT applications

Re: JCL to copy first 50 records

PostPosted: Tue Dec 07, 2010 11:31 pm
by Frank Yaeger
WER224A SORTIN NOT DEFINED


It's not that Sort (syncsort) didn't work - it's that YOU did not have the correct DD statements. SORTIN and SORTOUT are needed - not SYSUT1 and SYSUT2. I guess you didn't notice the difference between your job and mine, or bother to pick up a manual, or pay attention to the error message, or any of a number of other things that would have let you solve the problem yourself. You might want to try harder next time.