Page 1 of 1

Write the sort logic in COBOL.

Posted: Fri Jun 30, 2017 4:51 pm
by Ajit Shah
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?

Re: Write the sort logic in COBOL.

Posted: Fri Jun 30, 2017 6:07 pm
by nicc
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?

Re: Write the sort logic in COBOL.

Posted: Fri Jun 30, 2017 6:21 pm
by Robert Sample
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).

Re: Write the sort logic in COBOL.

Posted: Fri Jun 30, 2017 8:30 pm
by Anuj Dhawan
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.

Re: Write the sort logic in COBOL.

Posted: Mon Jul 03, 2017 5:00 pm
by Ajit Shah
Yes, I need to replicate SORT logic just uisng COBOL and not by calling some external SORT utility.

Re: Write the sort logic in COBOL.

Posted: Mon Jul 03, 2017 5:34 pm
by nicc
So answer all the questions.

Re: Write the sort logic in COBOL.

Posted: Mon Jul 03, 2017 6:01 pm
by Robert Sample
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?

Re: Write the sort logic in COBOL.

Posted: Mon Jul 10, 2017 4:46 pm
by Ajit Shah
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.

Re: Write the sort logic in COBOL.

Posted: Mon Jul 10, 2017 5:01 pm
by Robert Sample
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.