Write the sort logic in COBOL.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Ajit Shah
Registered Member
Posts: 13
Joined: Mon Oct 14, 2013 5:17 pm

Write the sort logic in COBOL.

Post 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?
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Write the sort logic in COBOL.

Post 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?
Regards
Nic
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1886
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Write the sort logic in COBOL.

Post 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).
User avatar
Anuj Dhawan
Founder
Posts: 2799
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: Write the sort logic in COBOL.

Post 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.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Ajit Shah
Registered Member
Posts: 13
Joined: Mon Oct 14, 2013 5:17 pm

Re: Write the sort logic in COBOL.

Post by Ajit Shah »

Yes, I need to replicate SORT logic just uisng COBOL and not by calling some external SORT utility.
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Write the sort logic in COBOL.

Post by nicc »

So answer all the questions.
Regards
Nic
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1886
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Write the sort logic in COBOL.

Post 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?
Ajit Shah
Registered Member
Posts: 13
Joined: Mon Oct 14, 2013 5:17 pm

Re: Write the sort logic in COBOL.

Post 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.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1886
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Write the sort logic in COBOL.

Post 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.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

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