Hi, Excellent explanation. Although code is giving correct results but it is not using bubble sort technique. In Bubble Sort, 1st number is getting compared with second and then second with third and so on. But as per the logic of code written, it is comparing 1st number with all the remaining numbers and putting the smallest number at first place. Now it will pick second number and compare with rest of the numbers and so on.
I am not sure which type of sort is this but definitely results are correct.
IBM MAINFRAME: Sort a internal array (table) in COBOL -:::: Author Message cheethra New User Joined: 20 Jan 2007 Location: India Posted: Thu Nov 01, 2007 7:48 pm Post subject: Sort a internal array (table) in COBOL Hi All, We have a requirement in which we cant go in for SORT PROCEDURE in COBOL using sort work files. Is there any way to sort the records in the internal table in A/D order based on the key of certain bytes in the records.
COBOL - Basic Syntax
Requirement is to similar to the Sort card we use for SYNCSORT. Thanks in Advance. CICS Guy Senior Member Joined: 18 Jul 2007 Location: At my coffee table Posted: Thu Nov 01, 2007 8:15 pm Post subject: I don't know about your 'sort card', but you can internally sort tables in various ways, give a look at this.
Tape backup software vista freeware, shareware, software download - Best Free Vista Downloads - Free Vista software download - freeware, shareware and trialware. Tape backup software vista.
DbzTHEdinosauer Global Moderator Joined: 20 Oct 2006 Location: porcelain throne Posted: Fri Nov 02, 2007 2:46 pm Post subject: cheethra, I would suggest you start with the Bubble Sort link provided by CICSGuy. You will always need a third area/field to save one of the items during the switch of the lesser and the greater. Revel Active User Joined: 05 Apr 2005 Location: Bangalore/Chennai-INDIA Posted: Fri Nov 02, 2007 2:57 pm Post subject: Hi Small correction, Use below code for SORTING - WORKING STORAGE SECTION. 01 WS-NUMBERS.
10 WS-NUM PIC 999 OCCURS 10 TIMES. 01 WS-I PIC 99. 01 WS-J PIC 99. 01 WS-K PIC 99. 01 WS-TEMP PIC 999. PROCEDURE DIVISION. PERFORM 1000-READ VARYING WS-I FROM 1 BY 1 UNTIL WS-I 10.
COMPUTE WS-J = WS-I + 1. PERFORM 2000-COMPARE VARYING WS-K FROM WS-J BY 1 UNTIL WS-K = 10. LOGIC FOR ORDERING NUMBERS IN ASC. IF WS-NUM(WS-I) WS-NUM(WS-K) MOVE WS-NUM(WS-I) TO WS-TEMP MOVE WS-NUM(WS-K) TO WS-NUM(WS-I) MOVE WS-TEMP TO WS-NUM(WS-K) ELSE CONTINUE END-IF.
- 2000-COMPARE. LOGIC FOR ORDERING NUMBERS IN DESC. IF WS-NUM(WS-I) WS-NUM(WS-K) CONTINUE ELSE MOVE WS-NUM(WS-I) TO WS-TEMP MOVE WS-NUM(WS-K) TO WS-NUM(WS-I) MOVE WS-TEMP TO WS-NUM(WS-K) END-IF. Use above pseudo code.
Regards, Raghavendra cheethra New User Joined: 20 Jan 2007 Location: India Posted: Fri Nov 02, 2007 3:51 pm Post subject: Hi All, Thanks for your replies. Let me explain what i wanted to do.
Assume there are five records of length 80 in a table, i wanted to pick few fields from each record and form a key, with this key i wanted to sort the records. Thanks, revel Active User Joined: 05 Apr 2005 Location: Bangalore/Chennai-INDIA Posted: Fri Nov 02, 2007 4:41 pm Post subject: cheethra wrote: Assume there are five records of length 80 in a table, i wanted to pick few fields from each record and form a key, with this key i wanted to sort the records.
![Program Program](/uploads/1/2/3/9/123954916/905182421.jpg)
COBOL Sorting COBOL Sort Statement The Sort Statement Specifies:. The source of the records to be sorted (source file). The Key Field(s). The sequencing desired (ascending or descending). The destination for the sorted files (destination file).
The name of a sort work-file that will be used by the sort-merge routine to accomplish the sort. What the Sort Statement Does. Opens the source file, destination file, and sort work-file.
![Sorting Sorting](/uploads/1/2/3/9/123954916/344331619.png)
Reads the records in the source file and copies them to the sort work-file. Sorts the records in the sort work-file according to the specified key fields. Copies the sorted records from the sort work-file into the destination file. Closes the source file, destination file and sort work-file. Preparing for the SORT In the Environment Division. SELECT source-file ASSIGN TO DISK “A:source.dat” ORGANIZATION IS LINE SEQUENTIAL.
SELECT destination-file ASSIGN TO DISK “A:destin.dat” ORGANIZATION IS LINE SEQUENTIAL. SELECT sort-work-file ASSIGN TO DISK “A:destin.dat”. In the DATA DIVISION SD sort-work-file DATA RECORD IS sort-buffer. 01 sort-buffer. 05 FILLER PIC X( ). 05 key-field-1 PIC. 05 FILLER PIC X( ).
05 key-field-2 PIC. In defining the sort-buffer, you only need to define the key fields you want to sort on. All the other fields may be defined as FILLER. Be sure to maintain the same offsets from the beginning of the record as in your source-file record. The SORT Statement SORT sort-work-file ON ASCENDING (or DESCENDING) KEY key-fld-1 ON ASCENDING (or DESCENDING) KEY key-fld-2 USING source-file GIVING destination-file.
Sort Example: 1. In the environment division SELECT stock-file ASSIGN TO DISK “A:stock.dat” ORGANIZATION IS LINE SEQUENTIAL. SELECT sorted-file ASSIGN TO DISK “A:sorted.dat” ORGANIZATION IS LINE SEQUENTIAL. SELECT work-file ASSIGN TO DISK “A:sort.wrk”. In the DATA Division SD WORK-FILE DATA RECORD IS SORT-REC. 01 SORT-REC 05 INVOICE-SORT PIC X(6). 05 FILLER PIC X(2).
05 SALESPERSON-SRT PIC X. 05 FILLER PIC X(71). In the Procedure Division SORT WORK-FILE ON ASCENDING KEY SALEPERSON-SRT ON ASCENDING KEY INVOICE-SORT USING STOCK-FILE GIVING SORTED-FILE. Source file = STOCK-FILE. Destination file = SORTED-FILE. KEY Fields = SALESPERSON-SRT (primary); INVOICE-SORT (secondary).
Tried to get help from Comcast but it was very frustrating -- multiple telephone disconnects, on-line chat disconnects, and then emailed query and received email responses that are progressively more incompetent responses that kept asking for information provided in the original question or subsequent responses. Arris tg862g turn on wifi. How do I turn off the WiFi on the TG852G modem? The configuration screens allow me to set security and choose channel, but that is not what I want to do. I have a new Arris TG852G modem from Comcast. I have my own WiFi routers and do *NOT* want Comcast provided WiFi.
Sorting Array In Cobol Program
Sequencing = ASCENDING. Sort-work-file = WORK-FILE SORT with INPUT/OUTPUT Procedures SORT sort-work-file ON ASCENDING (or DESCENDING) KEY key-fld-1 ON ASCENDING (or DESCENDING) KEY key-fld-2 INPUT PROCEDURE IS section-name-1 OUTPUT PROCEDURE IS section-name-2.
Example SORT WORK-FILE ON ASCENDING KEY SALEPERSON-SRT ON ASCENDING KEY INVOICE-SORT INPUT PROCEDURE IS 1000-PRE-SORT OUTPUT PROCEDURE IS 2000-POST-SORT. Addition Statements Needed with SORT with INPUT/OUTPUT Procedures GO TO Paragraph-name. RELEASE sort-buffer FROM dataname. (similar to write) RETURN sort-work-file RECORD INTO dataname AT END statement. (similar to read) SORT RULES. Never open or close the sort work-file.
Define the sort work-file with an SD entry (not an FD). Do not open the source file or destination file prior to the SORT (when using SORT with USING/GIVING option). They must be closed when the SORT statement executes.
The sort work-file must be assigned to disk, a direct access storage device. Use RETURN and RELEASE when referencing the sort work-file (when using the INPUT/OUTPUT procedures method). Neither an INPUT or OUTPUT procedure may contain a SORT statement. Neither an INPUT procedure nor an OUTPUT procedure may reference a paragraph or section outside the procedure.
Click download button to download Understanding pointers in c by yashwant kanetkar ebook Sneaking is difficult and often fails without understanding pointers HYPERPEN.
Mar 14, 2003 Understanding Pointers in C has 502 ratings and 19 reviews: Published March 8th 2007 by BPB Publications, 501 pages, Paperback.
![Ebook Ebook](/uploads/1/2/3/9/123954916/837361252.jpg)
Sorting In Cobol
To exist a section, branch to its last paragraph using a GO TO statement. That last paragraph may only contain an EXIT statement. The use of GO TO is restricted to use in INPUT/OUTPUT procedures for COBOL!!! Don’t try to use it elsewhere.