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
 

 

Preserve order using internal COBOL SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Preserve order using internal COBOL SORT
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Mon Apr 23, 2012 9:33 pm    Post subject: Reply to: Preserve order using internal COBOL SORT
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    Post subject: Reply to: Preserve order using internal COBOL SORT
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Mon Apr 23, 2012 10:05 pm    Post subject: Reply to: Preserve order using internal COBOL SORT
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

Site Director


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

PostPosted: Tue Apr 24, 2012 12:32 am    Post subject:
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    Post subject: Reply to: Preserve order using internal COBOL SORT
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

Site Director


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

PostPosted: Tue Apr 24, 2012 8:37 pm    Post subject: Reply to: Preserve order using internal COBOL SORT
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    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 Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
No new posts Order BY AND Index Nileshkul DB2 2 Sat Dec 31, 2016 6:33 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm


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