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

Need to stop sorting after 570 records


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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
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
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

Superior Member


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

PostPosted: Thu May 17, 2007 3:24 pm
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
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
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

Superior Member


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

PostPosted: Thu May 17, 2007 3:36 pm
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
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

Superior Member


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

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

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

Superior Member


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

PostPosted: Thu May 17, 2007 3:52 pm
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
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

Superior Member


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

PostPosted: Thu May 17, 2007 9:01 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
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
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top