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

Preserve order using internal COBOL SORT


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Mon Apr 23, 2012 9:14 pm
Reply with quote

Hi,

I am getting different result if I am sorting file using COBOL Program internal sort keeping the sort criteria same.

I want to sort a file with approx 100 records

Input file (i.e. work file)

Code:

B92   BNCJT FAIRMONT HAWAII B&M QS           01/01/2011 A92              9.00-
B93   BNGVF FAIRMONT HAWAII B&M QS           01/01/2012 AA5            151.00
EB1   BMXDG EQUIPMENT BREAKDOWN QS CMM       10/01/2010 AA5             27.00
EB1   BNGVM EQUIPMENT BREAKDOWN QS CMM       01/01/2012 AY1          1,111.00
B92   BNCJT FAIRMONT HAWAII B&M QS           01/01/2011 962            117.00-
B93   BNGVF FAIRMONT HAWAII B&M QS           01/01/2012 C48          5,870.00
EB1   BMXDG EQUIPMENT BREAKDOWN QS CMM       10/01/2010 AA5            127.00
EB1   BNGVM EQUIPMENT BREAKDOWN QS CMM       01/01/2012 AY1          4,747.00
B92   BNCJT FAIRMONT HAWAII B&M QS           01/01/2011                126.00-
B93   BNGVF FAIRMONT HAWAII B&M QS           01/01/2012              6,021.00
EB1   BMXDG EQUIPMENT BREAKDOWN QS CMM       10/01/2010                154.00


Desired output is as follows :-
I am getting desired output if I give SORT 2,12 on the input file (eg. B92 BNCJT)

Code:

B92   BNCJT FAIRMONT HAWAII B&M QS           01/01/2011 A92              9.00-
B92   BNCJT FAIRMONT HAWAII B&M QS           01/01/2011 962            117.00-
B92   BNCJT FAIRMONT HAWAII B&M QS           01/01/2011                126.00-
B93   BNGVF FAIRMONT HAWAII B&M QS           01/01/2012 AA5            151.00
B93   BNGVF FAIRMONT HAWAII B&M QS           01/01/2012 C48          5,870.00
B93   BNGVF FAIRMONT HAWAII B&M QS           01/01/2012              6,021.00
EB1   BMXDG EQUIPMENT BREAKDOWN QS CMM       10/01/2010 AA5             27.00
EB1   BMXDG EQUIPMENT BREAKDOWN QS CMM       10/01/2010 AA5            127.00
EB1   BMXDG EQUIPMENT BREAKDOWN QS CMM       10/01/2010                154.00
EB1   BNGVM EQUIPMENT BREAKDOWN QS CMM       01/01/2012 AY1          1,111.00
EB1   BNGVM EQUIPMENT BREAKDOWN QS CMM       01/01/2012 AY1          4,747.00
EB1   BNGVM EQUIPMENT BREAKDOWN QS CMM       01/01/2012              5,858.00


Actual output after doing interal COBOL program sort using below sort definition is as follows:-

SORT SORT-FILE ASCENDING KEY
SORT-KEY-TRTY-NO
SORT-KEY-R2K-TRTY-NO
USING WORK-FILE
OUTPUT PROCEDURE IS 800-PRINT-REPORTS.

Code:

B92   BNCJT FAIRMONT HAWAII B&M QS           01/01/2011 962            117.00-
B92   BNCJT FAIRMONT HAWAII B&M QS           01/01/2011                126.00-
B92   BNCJT FAIRMONT HAWAII B&M QS           01/01/2011 A92              9.00-
B93   BNGVF FAIRMONT HAWAII B&M QS           01/01/2012 AA5            151.00
B93   BNGVF FAIRMONT HAWAII B&M QS           01/01/2012 C48          5,870.00
B93   BNGVF FAIRMONT HAWAII B&M QS           01/01/2012              6,021.00
EB1   BMXDG EQUIPMENT BREAKDOWN QS CMM       10/01/2010 AA5             27.00
EB1   BMXDG EQUIPMENT BREAKDOWN QS CMM       10/01/2010                154.00
EB1   BMXDG EQUIPMENT BREAKDOWN QS CMM       10/01/2010 AA5            127.00
EB1   BNGVM EQUIPMENT BREAKDOWN QS CMM       01/01/2012 AY1          4,747.00
EB1   BNGVM EQUIPMENT BREAKDOWN QS CMM       01/01/2012              5,858.00
EB1   BNGVM EQUIPMENT BREAKDOWN QS CMM       01/01/2012 AY1          1,111.00


Could someone guide me on how can I preserve the order of records using internal sort?

Thanks in advance
Neil
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Apr 23, 2012 9:33 pm
Reply with quote

Have a look at DUPLICATES in the manual.

EDIT: I could have worded that better. I don't mean look for duplicate pages, lines or anything, but look in the index, or search, for the word DUPLICATES and you'll probably be satisfied.
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Mon Apr 23, 2012 9:59 pm
Reply with quote

Hi Bill,

I am able to achieve the same using external SORT using EQUALS as below:

//S1 EXEC PGM=SYNCSORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=CMTEST.MP.TEST.WORKIO,DISP=SHR
//SORTOUT DD DSN=CMTEST.MP.TEST.SORT1,
// DISP=(,CATLG,DELETE),UNIT=SYSDA,SPACE=(TRK,(15,5)),
// DCB=(RECFM=FB,LRECL=133,BLKSIZE=0)
//SYSIN DD *
SORT FIELDS=(2,12,CH,A),
EQUALS
/*
//

However I want to achieve the same result using internal sort/COBOL sort

Any idea on what keyword I can use equivalent to EQUALS keyword in SYNCSORT?

Please help.

Thanks in advance
Neil
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Apr 23, 2012 10:05 pm
Reply with quote

Mmmm.... let me think... errr.... I know!

How about looking at DUPLICATES in the manual!

EDIT: For information. Cobol will use your installed Sort product for sorting. So your question is, "how do I tell the installed sort product to do "equals" from a Cobol sort".

Further EDIT: I don't know about your documentation, but DFSORT documents how to supply information for an external-language sort and how various things can be done in a different way, including what you want, than external-language statements. More manuals for you to look at :-)
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Apr 24, 2012 12:32 am
Reply with quote

Hello,

If my memory is working, i believe you can specify EQUALS in a
//$ORTPARM DD. The manual should have info. I don't have my Syncsort documentation available today.

Suggest you look the informational messages when the internal sort is run and see how/if the EQUALS parameter is set.
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Tue Apr 24, 2012 10:11 am
Reply with quote

Hi,

The problem is solved. I used below internal sort statements:-

Code:

SORT SORT-FILE ON ASCENDING KEY       
          SORT-KEY-TRTY-NO           
          SORT-KEY-R2K-TRTY-NO       
WITH DUPLICATES IN ORDER             
USING WORK-FILE                       
OUTPUT PROCEDURE IS 800-PRINT-REPORTS.


'WITH DUPLICATES IN ORDER' is equivalent to EQUALS in Syncsort.


Thank you all for your guidance.
Neil
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Apr 24, 2012 8:37 pm
Reply with quote

Good to hear it is working - thank you for letting us know icon_smile.gif

The DUPLICATES IN ORDER is not specific to Syncsort.

And the $ORTPARM DD is supported by Syncsort.

d
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top