Sorting An Array In Cobol Program

Posted on  by admin

Sort an array in COBOL. I will advice against implementing your own sorting algoritm. It makes your program harder to maintain. Jul 02, 2011 But trust me there can be situations in CICS-COBOL program. COBOL program for BUBBLE SORT (COBOL program for sorting an array). COBOL Programming: Hi all, How to sort an array? My problem is: There is an one dim array, 01 ITEM-VAR. 05 ITEM OCCURS 150.

  1. Sorting Arrays Java
  2. Sorting An Array In Javascript
  3. Sorting An Array In C++
Vba

Code for PROGRAM TO SORT THE RECORDS OF FILE in Cobol IDENTIFICATION DIVISION. ENVIRONMENT DIVISION. SELECT IN-FILE ASSIGN TO 'INPUT.TXT' ORGANIZATION IS LINE SEQUENTIAL.

Sorting Arrays Java

SELECT SORT-FILE ASSIGN TO SYSWORK. SELECT OUT-FILE ASSIGN TO 'SORT.TXT' ORGANIZATION IS LINE SEQUENTIAL. DATA DIVISION. FILE SECTION. FD IN-FILE LABEL RECORDS ARE STANDARD. 05 ROLLNO PIC 99.

Sorting An Array In Javascript

05 NAME1 PIC X(10). SD SORT-FILE. 05 NO1 PIC 99. 05 PIC X(10). FD OUT-FILE LABEL RECORDS ARE STANDARD. 05 ROLLNO1 PIC 99.

05 NAME2 PIC X(10). WORKING-STORAGE SECTION.

01 EOF PIC X VALUE 'N'. PROCEDURE DIVISION.

Algorithm for sorting an array

SORT SORT-FILE ON ASCENDING KEY NO1 INPUT PROCEDURE PARA1 GIVING OUT-FILE STOP RUN. OPEN INPUT IN-FILE PERFORM UNTIL EOF= 'Y' READ IN-FILE AT END MOVE 'Y' TO EOF NOT AT END MOVE IN-REC TO SORT-REC RELEASE SORT-REC END-READ END-PERFORM CLOSE IN-FILE. OUTPUT. INPUT.TXT 01APURVA 04NILAY 03KETAN SORT.TXT 01APURVA 03KETAN 04NILAY.

IBM MAINFRAME: How to sort an array in COBOL -:::: Author Message Rajiv Lochan De New User Joined: 27 Dec 2007 Location: kolkata Posted: Fri Jun 06, 2008 5:25 pm Post subject: How to sort an array in COBOL Hi all, How to sort an array? My problem is: There is an one dim array, 01 ITEM-VAR. 05 ITEM OCCURS 150 TIMES. 10 DEL-DATE PIC S9(09) COMP-3. 10 DEPT-NEBR PIC S9(04) COMP-3. 10 DISP PIC X(01). I want to sort this table by DEL-DATE and then within a date by DISP.

If my input array is: 30/06/07 20 R 10/06/07 30 S 20/06/07 30 R 30/06/07 20 A 10/06/07 30 R 30/06/07 40 S 30/06/07 20 R Then output array will be 10/06/07 30 R 10/06/07 30 S 20/06/07 30 R 30/06/07 20 A 30/06/07 20 R 30/06/07 20 R 30/06/07 40 S Thanks, Rajiv. Craq Giegerich Senior Member Joined: 19 May 2007 Location: Virginia, USA Posted: Fri Jun 06, 2008 5:32 pm Post subject: What is the date format, I can see that it is COMP-3 is it in yyyymmdd format or mmddyyyy or ddmmyyyy?

Rajiv Lochan De New User Joined: 27 Dec 2007 Location: kolkata Posted: Fri Jun 06, 2008 5:36 pm Post subject: Date format is yyyymmdd itdsen New User Joined: 20 Sep 2006 Location: Chennai Posted: Wed Jun 11, 2008 7:29 pm Post subject: Reply to: how to sort an array Is it possible declare date field in comp3. Comp3 only used only with numeric. Craq Giegerich Senior Member Joined: 19 May 2007 Location: Virginia, USA Posted: Wed Jun 11, 2008 8:11 pm Post subject: Re: Reply to: how to sort an array itdsen wrote: Is it possible declare date field in comp3. Comp3 only used only with numeric. You don't declare a date as comp-3, you declare a field as comp-3 and use it store a numeric value representing a date. 20080611 will fit into a pic s9(9) comp-3 field with no problems, COBOL doesn't know it's a date but the programmers do. Robert Sample Global Moderator Joined: 06 Jun 2008 Location: Dubuque, Iowa, USA Posted: Wed Jun 11, 2008 8:42 pm Post subject: Reply to: how to sort an array In batch you can invoke the system sort via the SORT verb - see manual for SD and so forth needed.

Cobol

Or, you can implement a sort algorithm from any college text book in your code. In CICS you don't have access to system sort so you'll have to implement a sort algorithm against the array. Ashimer Active Member Joined: 13 Feb 2004 Location: Bangalore Posted: Wed Jun 11, 2008 8:46 pm Post subject: Use this piece of code.

Sorting An Array In C++

Code: 01 SAVE-CODE1 PIC 9(9) VALUE SPACES. 01 SAVE-CODE2 PIC S9(9) VALUE SPACES. 01 SAVE-CODE3 PIC X VALUE SPACES. 01 S1 PIC S9(4) COMP VALUE 0. 01 S2 PIC S9(4) COMP VALUE 0. 05 ITEM OCCURS 150 TIMES.

10 DEL-DATE PIC S9(09) COMP-3. 10 DEPT-NEBR PIC S9(04) COMP-3. 10 DISP PIC X(01).

PERFORM VARYING S1 FROM 1 BY 1 UNTIL S1 = 150 PERFORM VARYING S2 FROM S1 BY 1 UNTIL S2 150 IF DEL-DATE(S2) All times are GMT + 6 Hours Page 1 of 1 Search our Forum.