Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Table sort in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
prashanthkumar_hs

New User


Joined: 30 Jun 2005
Posts: 1

PostPosted: Thu Jun 30, 2005 4:41 am    Post subject: Table sort in cobol
Reply with quote

The working storage section is:
05 WS-INFO OCCURS 103 TIMES
INDEXED BY A1.
10 PROD-D1 PIC X(15).
10 CASH-2 PIC S9(05)V99 COMP-3.
10 CASH-REFUND PIC S9(05)V99 COMP-3.
10 CASH-NET PIC S9(05)V99 COMP-3.
:
:
I want to sort the WS-INFO is to be sorted in ascending sequence based on PROD-D1 field from 4th occurrence to 103rd occurrence.
Could you please suggest how to implement in the program. I want full code.
Back to top
View user's profile Send private message

mdtendulkar

Active User


Joined: 29 Jul 2003
Posts: 238
Location: USA

PostPosted: Tue Aug 09, 2005 5:19 am    Post subject: Re: Table sort in cobol
Reply with quote

prashanthkumar_hs,

How about referring this link and come up with the logic you desired?
Following link will give you a similar code as per your requiremnt.

http://home.att.net/~arnold.trembley/svalgard.htm

Hope this helps,

Regards
Mayuresh
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 241
Location: Cincinnati OH USA

PostPosted: Tue Aug 09, 2005 8:18 am    Post subject:
Reply with quote

Just use COBOL's SORT verb with input and output procedures to give records (table entries) to SORT and reload table upon SORT returning those records.


Dave
Back to top
View user's profile Send private message
fixdoubts

New User


Joined: 21 Oct 2005
Posts: 54

PostPosted: Thu Nov 24, 2005 5:47 pm    Post subject: Re: Table sort in cobol
Reply with quote

PERFORM
VARYING X FROM 4 BY 1 UNTIL X > 101

COMPUTE Y = 101 - X

PERFORM
VARYING Z FROM 4 BY 1 UNTIL Z > Y

MOVE PROD-P1(Z) TO TEMP1
MOVE PROD-P1(Z+1) TO TEMP2

IF ( TEMP1 > TEMP2)
INTERCHANGE THE TABLE ENTRIES FOR Z AND Z+1
ELSE
CONTINUE
END-IF
END-PERFORM
END-PERFORM

THIS MIGHT HELP

REGARDS,
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us