Write the sort logic in COBOL.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.

Topic author
Ajit Shah
Registered Member
Posts: 13
Joined: Mon Oct 14, 2013 5:17 pm

Write the sort logic in COBOL.

Postby Ajit Shah » Fri Jun 30, 2017 4:51 pm

Hi,

I need to write a COBOL program to sort the file in ascending order without sort. As sort is not working in Micro Focus language. Can somebody please guide on this?




nicc
Global Moderator
Global Moderator
Posts: 544
Joined: Wed Apr 23, 2014 8:45 pm
Been thanked: 11 times

Re: Write the sort logic in COBOL.

Postby nicc » Fri Jun 30, 2017 6:07 pm

What do you mean by "not working"?
What environment are you running in?
If MF sort is not working have you contacted MF?

Which sort algorithm do you want?


Regards
Nic

Online
User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1275
Joined: Fri Jun 28, 2013 1:22 am
Location: East Dubuque Illinois
Has thanked: 2 times
Been thanked: 90 times

Re: Write the sort logic in COBOL.

Postby Robert Sample » Fri Jun 30, 2017 6:21 pm

Find the COBOL language reference for your Micro Focus product.
Read the language reference on the SORT verb.

COBOL has the SORT verb which allows sorting without needing anything else. You cannot do complicated SORT logic using JOINKEYS and so forth, but you can use an INPUT PROCEDURE or OUTPUT PROCEDURE to replace some of the SORT user exits available in the mainframe SORT package.

And if SORT is not working in Micro Focus, why are you not on the vendor site requesting assistance from them? If their SORT is not working, and you or your site have a license for the product, they should provide help (unless you are clearly violating one of their limitations).



User avatar

Anuj Dhawan
Founder
Posts: 2392
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Has thanked: 152 times
Been thanked: 66 times

Re: Write the sort logic in COBOL.

Postby Anuj Dhawan » Fri Jun 30, 2017 8:30 pm

I think he is trying to mimic bubble sort, insertion sort or other variants using COBOL without really calling SORT product at shop. Just a guess though.


Thanks,
Anuj


Topic author
Ajit Shah
Registered Member
Posts: 13
Joined: Mon Oct 14, 2013 5:17 pm

Re: Write the sort logic in COBOL.

Postby Ajit Shah » Mon Jul 03, 2017 5:00 pm

Yes, I need to replicate SORT logic just uisng COBOL and not by calling some external SORT utility.




nicc
Global Moderator
Global Moderator
Posts: 544
Joined: Wed Apr 23, 2014 8:45 pm
Been thanked: 11 times

Re: Write the sort logic in COBOL.

Postby nicc » Mon Jul 03, 2017 5:34 pm

So answer all the questions.


Regards
Nic

Online
User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1275
Joined: Fri Jun 28, 2013 1:22 am
Location: East Dubuque Illinois
Has thanked: 2 times
Been thanked: 90 times

Re: Write the sort logic in COBOL.

Postby Robert Sample » Mon Jul 03, 2017 6:01 pm

Yes, I need to replicate SORT logic just uisng COBOL and not by calling some external SORT utility.
You STILL have not explained what you need. Use the COBOL SORT verb -- see https://www.ibm.com/support/knowledgece ... y5lr10.pdf for details. That uses nothing but COBOL -- no external SORT utility required. If you want to implement a sort algorithm in COBOL, that is a very different matter, and the first question would be WHY NOT USE THE SORT VERB?




Topic author
Ajit Shah
Registered Member
Posts: 13
Joined: Mon Oct 14, 2013 5:17 pm

Re: Write the sort logic in COBOL.

Postby Ajit Shah » Mon Jul 10, 2017 4:46 pm

I will have a file like this:

0010
0009
0003
0008
0007
0005
0002
0001
0006
0004

and I want to sort them in ascending order. I can do it using by calling the SORT but I need to use using a COBOL program logic.



Online
User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1275
Joined: Fri Jun 28, 2013 1:22 am
Location: East Dubuque Illinois
Has thanked: 2 times
Been thanked: 90 times

Re: Write the sort logic in COBOL.

Postby Robert Sample » Mon Jul 10, 2017 5:01 pm

Google is your friend. Googling sort algorithms returned about 563,000 results and several on the first page give you algorithms to code up. Please note that this is a HELP forum, not a WRITE-THE-CODE-FOR-YOU forum. If you want somebody to write the code for you, plan on paying for that person's expertise.




Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”

Who is online

Users browsing this forum: CommonCrawl [Bot] and 2 guests