Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need to stop sorting after 570 records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
khkalyan

New User


Joined: 14 May 2007
Posts: 5
Location: India

PostPosted: Thu May 17, 2007 12:35 pm    Post subject: Need to stop sorting after 570 records
Reply with quote

I have a file of 1000 records . I need to stop sorting after 570 records .
can any one of you resolve it.
Back to top
View user's profile Send private message

Raphael Bacay

New User


Joined: 04 May 2007
Posts: 58
Location: Manila, Philippines

PostPosted: Thu May 17, 2007 1:58 pm    Post subject: Re: Need to stop sorting after 570 records
Reply with quote

There could be problems with your requirement. The problem is that for example, the lowest element is in the 1000th position. If you want to sort the first 570 records only, you will miss out the first element of the 1000 element file because you will never get to the first record with the 570 limit. You might want to just sort everything up, all 1000, and then extract the first 570 so you get the 570 records in sorted order. You can use IDCAMS-REPRO with COUNT for this or make a COBOL program to extract the first 570 elements.

If you insist that you only need the first 570 elements then you can just extract the first 570 records using IDCAMS-REPRO with COUNT or COBOL. Then you can use COBOL or JCL to sort the 570 element file into sorted order.

If you are going to try the IDCAMS option for extract you might want to use the REPRO parameter with syntax:

REPRO -
INFILE(VSAM) -
OUTFILE(SEQ) -
COUNT(N)

You can then use SYNCSORT or COBOL for the sorting.
Back to top
View user's profile Send private message
skkp2006

New User


Joined: 14 Jul 2006
Posts: 93
Location: Chennai,India

PostPosted: Thu May 17, 2007 2:15 pm    Post subject: Re: Need to stop sorting after 570 records
Reply with quote

STOPAFT Parameter (Optional) (SyncSort OS/DOS compatible)

STOPAFT=n instructs SyncSort CMS to sort or copy only a decimal number (n) of records. These will be the first 'n' records after E15, INCLUDE/OMIT and SKIPREC processing.

The STOPAFT parameter may be specified on the OPTION control statement, but should not be specified on both the SORT statement and the OPTION statement for the same application.

STOPAFT may also be specified as an option on the SSORT command line. If it is, it overrides any STOPAFT parameters on the SyncSort CMS control statements.
Back to top
View user's profile Send private message
priyamnavada

New User


Joined: 24 Dec 2005
Posts: 52
Location: hyderabad

PostPosted: Thu May 17, 2007 2:33 pm    Post subject:
Reply with quote

Use STOPAFT=570
Back to top
View user's profile Send private message
khkalyan

New User


Joined: 14 May 2007
Posts: 5
Location: India

PostPosted: Thu May 17, 2007 2:39 pm    Post subject: Re: Need to stop after 570 records
Reply with quote

Sorry there is a confusion in my question.I want to write first 570 records of 1000 records in to separate output file.The processiong has to stop after wrirting 570 records.
Back to top
View user's profile Send private message
SHAILESH OZA

New User


Joined: 10 Jun 2005
Posts: 21
Location: Mumbai

PostPosted: Thu May 17, 2007 3:04 pm    Post subject:
Reply with quote

Hi Chankravarti,

you can follow the below steps

1) First read the 570 records from the input file File1 and write these records into the output file2.

2) Then Sort the file2.

3) Then simply read the input file1 upto the record 570(you can use perform 570 times).

4) After that open the file2 in extend mode and append the records into it
after making sure that your pointer in the input file is at the record 571.

This is the logic only . Bytherway i will try to implement it and let you know
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu May 17, 2007 3:24 pm    Post subject:
Reply with quote

Hi khkalyan,

Used below JCL to check STOPAFT. It's working fair enough for your requirement.
Code:
//JOBCARD
//*                                         
//STEP050  EXEC PGM=SORT,REGION=4096K       
//*                                         
//SORTIN   DD  DSN=HLQ.TEMP.FILE,       
//             DISP=SHR                     
//SORTOUT  DD  DSN=HLQ.TEMP.FILE1,       
//             DISP=(NEW,CATLG,CATLG),       
//             DSORG=PS,                     
//             RECFM=FB,                     
//             DATACLAS=LARGE,               
//             UNIT=SYSDA                   
//SORTWK01 DD  UNIT=SYSDA,SPACE=(CYL,(20,5))
//SYSIN    DD  *           
  SORT FIELDS=(1,10,CH,A),STOPAFT=5     
/*                         
//SORTMSG  DD  SYSOUT=*     
//SYSOUT   DD  SYSOUT=*     
//SYSPRINT DD  SYSOUT=*     
//SYSUDUMP DD  SYSOUT=*     
//CEEDUMP  DD  SYSOUT=*     
//*                         


Data in i/p:HLQ.TEMP.FILE
Code:
9000000000
8000000000
7000000000
6000000000
5000000000
4000000000
3000000000
2000000000
1000000000
0000000000

Data in o/p:
Code:
5000000000
6000000000
7000000000
8000000000
9000000000

Hope it helps.
Back to top
View user's profile Send private message
khkalyan

New User


Joined: 14 May 2007
Posts: 5
Location: India

PostPosted: Thu May 17, 2007 3:27 pm    Post subject:
Reply with quote

Hi this is ok.But I need to do with JCL.
Back to top
View user's profile Send private message
khkalyan

New User


Joined: 14 May 2007
Posts: 5
Location: India

PostPosted: Thu May 17, 2007 3:34 pm    Post subject: HI
Reply with quote

HI PRIYA THANKS A LOT

I GOT THE OUT FILE
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu May 17, 2007 3:36 pm    Post subject:
Reply with quote

Hi,

Just wanted to add the following in above,
I/P file contains 10 records & I want to stop sort after 5 records OR in other words, I want to sort first 5 records only.


for your situation:
I/P file contains 1000 records & you want to stop sort after 570 records OR in other words, want to sort first 570 records only. icon_wink.gif

Hope you got the solution. icon_smile.gif
Back to top
View user's profile Send private message
khkalyan

New User


Joined: 14 May 2007
Posts: 5
Location: India

PostPosted: Thu May 17, 2007 3:38 pm    Post subject: HI
Reply with quote

HI ANJU I HAVE DONE LIKE THAT ONLY BUT I HAVE GIVEN LIKE THIS



//SYSIN DD *
OPTION COPY,
STOPAFT=5
/*
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu May 17, 2007 3:46 pm    Post subject:
Reply with quote

oopss..!..
my answer came bit late.!
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu May 17, 2007 3:52 pm    Post subject:
Reply with quote

aha..!!
You got the solution..good..!
By the way my name is Anuj & not Anju icon_sad.gif
Back to top
View user's profile Send private message
ramfrom84

New User


Joined: 23 Aug 2006
Posts: 93
Location: chennai

PostPosted: Thu May 17, 2007 4:59 pm    Post subject:
Reply with quote

HI ,

U can use STOPAFT in SORT similar in the IDCAMS we have one more Option

REPRO INFILE(INDD) OUTFILE(OUTDD0) SKIP(No of records) COUNT(mno of records)

Code:

//R010    EXEC PGM=CONDCODE,PARM=IDCAMS                       
//SYSPRINT DD  SYSOUT=*                                       
//INDD     DD  DSN=Input File ,DISP=SHR
//OUTDD0   DD  DSN=Output File,
//             DISP=(,CATLG,DELETE),                     
//             UNIT=SYSDA,                               
//             STORCLAS=CTSDASD,                         
//             DATACLAS=COMPRESS,                       
//             AVGREC=K,                                 
//             SPACE=(1250,(1500,600),RLSE),             
//             DCB=(RECFM=FB,LRECL=1250)                 
//SYSIN    DD  *                                                   
REPRO INFILE(INDD) OUTFILE(OUTDD0) SKIP(No of records) COUNT(mno of records)
/*                           
//SYSOUT   DD  SYSOUT=*       
//*                           
//                           



This would be better for ur requriment if it is o/p is VSAM File..

Thanks..
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu May 17, 2007 9:01 pm    Post subject:
Reply with quote

ramfrom84 wrote:
HI ,

U can use STOPAFT in SORT similar in the IDCAMS we have one more Option



I used STOPAFT in SORT only.. icon_rolleyes.gif . I didn't get you.

& what is CONDCODE in your JCL? When I tried your JCL, here at my site, got the message "Program CONDCODE not found". Please suggest.
Back to top
View user's profile Send private message
ramfrom84

New User


Joined: 23 Aug 2006
Posts: 93
Location: chennai

PostPosted: Fri May 18, 2007 3:48 pm    Post subject:
Reply with quote

Soory guys,, U can use IDCAMS, for Normal REPRO here.., It ll work... forgot about CONDCODE....

Code:

//R010    EXEC PGM=IDCAMS                       
//SYSPRINT DD  SYSOUT=*                                       
//INDD     DD  DSN=Input File ,DISP=SHR
//OUTDD0   DD  DSN=Output File,
//             DISP=(,CATLG,DELETE),                     
//             UNIT=SYSDA,                               
//             STORCLAS=CTSDASD,                         
//             DATACLAS=COMPRESS,                       
//             AVGREC=K,                                 
//             SPACE=(1250,(1500,600),RLSE),             
//             DCB=(RECFM=FB,LRECL=1250)                 
//SYSIN    DD  *                                                   
REPRO INFILE(INDD) OUTFILE(OUTDD0) SKIP(No of records) COUNT(mno of records)
/*                           
//SYSOUT   DD  SYSOUT=*       
//*                           
//                         


Thanks for correct me...
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts To Merge mutliple records into a sing... anandgbe DFSORT/ICETOOL 6 Wed Feb 22, 2017 8:49 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us