MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

JCL for Selecting records from a PS.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Thu Feb 27, 2003 6:17 am    Post subject: JCL for Selecting records from a PS. Reply with quote

Hi,

I have this really really huge PS which I have to process. However, for the Testing Part, Its not a good idea to use this entire file. Im looking out for a JCL using which I can take out the first 1000, 2000, 10000 or so records. Any one with something like this.

What about some conditions we want to put into the records we want to pull out. Say fields 4-6 should have this value and fields 10-14 should have this value and pull out a total of the first 1000, 2000 or so records matching this criteria. Would this be possible too.

Any help would be Great!!!! Thanks!!!!!

Regards,
Manoj.
Back to top
View user's profile Send private message
Tophe
Beginner


Joined: 02 Dec 2002
Posts: 8
Topics: 0
Location: Tours, France

PostPosted: Thu Feb 27, 2003 7:04 am    Post subject: Reply with quote

For the first question, you can use REPRO (IDCAMS) with the keywords COUNT ans SKIP

For the second question, you can do it with FILE-AID


HTH

Tophe
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Feb 27, 2003 7:18 am    Post subject: Reply with quote

manojagrawal,


The following JCL will give you the desired results.
Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=YOUR.INPUT FILE,
//            DISP=SHR
//SORTOF01 DD DSN=YOUR FIRST 1000 RECORDS,
//            DISP=(NEW.CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(XY,Y),RLSE)
//SORTOF02 DD DSN=YOUR SECOND 1000 RECORDS,
//            DISP=(NEW.CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(XY,Y),RLSE)
//SORTOF03 DD DSN=YOUR THIRD 1000 RECORDS,
//            DISP=(NEW.CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(XY,Y),RLSE)
//SYSIN DD *
  SORT FIELDS=COPY
  OUTFIL FILES=01,ENDREC=1000
  OUTFIL FILES=02,STARTREC=1001,ENDREC=2000
  OUTFIL FILES=03,STARTREC=2001,ENDREC=3000
/* 


If you want to include a condition for then you can do that also

simply change the above sysin cards to the following

Code:

//SYSIN DD *
  SORT FIELDS=COPY
  INCLUDE COND=(4,3,CH,EQ,C'ABC',AND,10,5,CH,EQ,C'MANOJ')
  OUTFIL FILES=01,ENDREC=1000
  OUTFIL FILES=02,STARTREC=1001,ENDREC=2000
  OUTFIL FILES=03,STARTREC=2001,ENDREC=3000
/* 

Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Feb 27, 2003 11:10 am    Post subject: Reply with quote

Manoj,

I think this DFSORT job might be more appropriate for what you asked for then the ones shown by Kolusu:

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN DD *
  INCLUDE COND=(4,3,CH,EQ,C'string1',AND,10,5,CH,EQ,C'string2')
  OPTION COPY,STOPAFT=n
/*


You can use the INCLUDE statement if you want to keep the first n records with the condition you specify (e.g. n=1000 to get the first 1000 records that match the condition). You can leave out the INCLUDE statement if you just want to keep the first n records (e.g. n=10000 to get the first 10000 records).
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Mon Mar 03, 2003 6:57 am    Post subject: Reply with quote

Hi Tophe, Kolusu, Frank

Thanks a ton! This Help Board seems to be great place. Just found it a few days back, and am really enjoying it.

Regards,
Manoj.
Back to top
View user's profile Send private message
gopinath
Beginner


Joined: 31 Mar 2003
Posts: 1
Topics: 0

PostPosted: Mon Mar 31, 2003 1:06 pm    Post subject: Reply with quote

Embarassed
Back to top
View user's profile Send private message
Nila
Beginner


Joined: 26 Dec 2002
Posts: 20
Topics: 8
Location: Chennai, India

PostPosted: Tue Apr 29, 2003 4:33 am    Post subject: Reply with quote

Hi
Suppose I want to copy the records with different conditions
in different files?

Example in the code:
INCLUDE COND=(4,3,CH,EQ,C'ABC',AND,10,5,CH,EQ,C'MANOJ')
these need to be put in one file and records which satisfying the following
INCLUDE COND=(4,3,CH,EQ,C'ABC',AND,10,5,CH,EQ,C'NEELS')
in another file..how to code this?

Cheers Neels
Back to top
View user's profile Send private message
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Tue Apr 29, 2003 5:50 am    Post subject: Reply with quote

Hi Neels,

Using SORT

Code:

//STEP10 EXEC PGM=SORT
//SYSOUT DD  SYSOUT=*                                           
//SORTIN   DD DSN=inputdd.name,DISP=SHR
//SORTOF1  DD DSN=outdd.name.first,             
//           DISP=(NEW,CATLG,DELETE),                           
//           UNIT=SYSDA,                                       
//           SPACE=(CYL,(50,10),RLSE)                   
//SORTOF2  DD DSN=outdd.name.second,             
//           DISP=(NEW,CATLG,DELETE),                           
//           UNIT=SYSDA,                                       
//           SPACE=(CYL,(50,10),RLSE)                           
//SYSIN DD *                                                   
  SORT FIELDS=COPY                                                   
  OUTFIL INCLUDE=(5,4,CH,EQ,C'AAAA',AND,1,2,CH,EQ,C'BB'),FILES=1
  OUTFIL INCLUDE=(5,4,CH,EQ,C'AAAA',AND,1,2,CH,EQ,C'CC'),FILES=2
/*                                                             



Using ICEMAN

Code:

//STEP10 EXEC PGM=ICEMAN                                       
//SYSOUT DD  SYSOUT=*                                           
//SORTIN   DD DSN=inputdd.name,DISP=SHR
//SORTOF1  DD DSN=outdd.name.first,             
//           DISP=(NEW,CATLG,DELETE),                           
//           UNIT=SYSDA,                                       
//           SPACE=(CYL,(50,10),RLSE)                   
//SORTOF2  DD DSN=outdd.name.second,             
//           DISP=(NEW,CATLG,DELETE),                           
//           UNIT=SYSDA,                                       
//           SPACE=(CYL,(50,10),RLSE)                           
//SYSIN DD *                                                   
  OPTION COPY                                                   
  OUTFIL INCLUDE=(5,4,CH,EQ,C'AAAA',AND,1,2,CH,EQ,C'BB'),FILES=1
  OUTFIL INCLUDE=(5,4,CH,EQ,C'AAAA',AND,1,2,CH,EQ,C'CC'),FILES=2
/*                                                             


If you have ICETOOL, this is what you can do.

Code:

//STEP10   EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*     
//INDD01   DD DSN=inputdd.name,DISP=SHR
//OUTDD01  DD DSN=outdd.name.first,                                 
//            DISP=(NEW,CATLG,DELETE),                                 
//            UNIT=SYSDA,                                             
//            SPACE=(CYL,(50,10),RLSE)                                 
//OUTDD02  DD DSN=outdd.name.second,                                 
//            DISP=(NEW,CATLG,DELETE),                                 
//            UNIT=SYSDA,                                             
//            SPACE=(CYL,(50,10),RLSE)                                 
//TOOLIN DD *                                                         
  COPY FROM(INDD01) USING(MULT)                                       
/*                                                                     
//MULTCNTL DD *                                                       
  OUTFIL FNAMES=OUTDD01,INCLUDE=(5,4,CH,EQ,C'AAAA',AND,1,2,CH,EQ,C'BB')
  OUTFIL FNAMES=OUTDD02,INCLUDE=(5,4,CH,EQ,C'AAAA',AND,1,2,CH,EQ,C'CC')
/*                                                                     


Hope this helps,
Regards,
Manoj.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Apr 29, 2003 10:55 am    Post subject: Reply with quote

Manoj,

The steps you show for SORT and ICEMAN will work with both. SORT FIELDS=COPY and OPTION COPY are equivalent. DFSORT accepts both of them and I believe our competitor does as well. The PGM=ICETOOL step you show for DFSORT's ICETOOL is actually the equivalent of the SORT and ICEMAN steps. FNAMES or FILES can be used in all cases.

My point is that you're making it look like different DFSORT control statement syntax is needed for these three methods, when in fact, the same DFSORT control statement syntax will work for all of them.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Wed Apr 30, 2003 2:28 am    Post subject: Reply with quote

ooops Surprised

Thanks Frank!!! I thought that was the syntax of each of the utilities!!! Nice to know it supports both. Moreover, the FNAMES and FILES got cleared for me too. Thanks!

Regards,
Manoj.
Back to top
View user's profile Send private message
vini
Intermediate


Joined: 12 Jan 2004
Posts: 240
Topics: 48
Location: Maryland

PostPosted: Wed Dec 29, 2004 5:53 pm    Post subject: Reply with quote

On the same lines if I need to evaluate a complex criteria for records selection from a flat file as below
Quote:

Tax Withheld >=15% of the Paid amount


If this is possible , pls tell me how. Tax witheld and Paid amount are 2 fields starting at 180 and 192 positions respectively and of length 12 in a file of length 465.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Dec 30, 2004 12:39 am    Post subject: Reply with quote

Vini,

You need to provide more details. You gave the starting position of Tax withheld and Paid Amount Fields, but what about the Picture Clauses for these fields.

Anyway I'm assuming this:
Tax Withheld - 9(9)
Amount - 9(9)

You may need to modify the code appropriately.

See if this helps,

Code:

//R010     EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=YOUR.INPUT.FILE,
//           DISP=SHR                                                       
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                   
  OUTREC FIELDS=(1,465,                          * COPY INPUT DATA   *
   192,9,ZD,MUL,+15,DIV,+100,EDIT=(TTTTTTTTT))   * 15% OF AMOUNT     *
  OUTFIL INCLUDE=(180,9,ZD,GE,466,9,ZD)          * COMPARE TAX & AMT *
/*                                                                   


Thanks,
Phantom
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Dec 30, 2004 12:59 am    Post subject: Reply with quote

Vini,

You can try this untested version. I assumed that your Tax witheld and Paid amount are defined as 9(12). we calculate the 15% of paid amount at pos 466 for every record. Now using include cond on OUTFIL we select the desired records.


Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD DSN=YOUR INPUT DSN,
//            DISP=SHR
//SORTOUT  DD DSN=YOUR OUTPUT DSN,             
//            DISP=(NEW,CATLG,DELETE),                           
//            UNIT=SYSDA,                                       
//            SPACE=(CYL,(X,Y),RLSE) 
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                               
  OUTREC FIELDS=(1,465,                  $ total lrecl
               (+15,MUL,192,12,ZD),      $ 15 times paid amount 
                DIV,+100,                $ divide by 100
                M11,LENGTH=12)           $ result in zd format of 12 bytes
 OUTFIL INCLUDE=(180,12,ZD,GE,466,12,ZD),  $ compare tax withheld to result
 OUTREC=(1,465)                            $ strip off the result
/*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group