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
 

 

Sorting the table

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

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Tue Feb 05, 2008 3:59 pm    Post subject: Sorting the table
Reply with quote

Hi,
I have a table consists of 48 records which will be populated in an asencding order. I want to sort that data in a descending order.

But the table has a Index variable. Can i use the subscript inorder to sort the data in that table?

for ex: 05 TABLE OCCURS 48 TIMES INDEXED BY A1
10 EMPNO PIC X(02)
10 EMPNAME PIC X(19)
10 SUBJECT PIC x(03)

and I have 48 records in ascending order (based on EMPNO). Now i want to sort the data in descending order. I can sort the by using subscripts.

PERFORM WI-MIN VARYING FROM 1 BY 1
UNTIL WI-MIN > TOTAL ROWS/2
MOVE TABLE (WI-MIN) TO WS-TEMP-REC
MOVE TABLE (WI-MAX) TO TABLE (WI-MIN)
MOVE WS-TEMP-REC TO TABLE (WI-MAX)
END-PERFORM

Is it possible to use the subscripts here? DO YOU HAVE ANY OTHER SOLUTION? Please assist me in this regards.
Thanks in advance
Narsimha
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Feb 05, 2008 4:05 pm    Post subject:
Reply with quote

Yes you can use subscripts or you can define additional indexes.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Tue Feb 05, 2008 4:27 pm    Post subject: Reply to: Sorting the table
Reply with quote

Quote:
DO YOU HAVE ANY OTHER SOLUTION?

You can access the array in reverse direction, for example-
Code:
PERFORM VARYING A1 FROM 48 BY -1......

This is not sorting but it should serve the purpose of getting the values in reverse order.
Back to top
View user's profile Send private message
simha_it

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Tue Feb 05, 2008 4:31 pm    Post subject: Re: Reply to: Sorting the table
Reply with quote

agkshirsagar wrote:
Quote:
DO YOU HAVE ANY OTHER SOLUTION?

You can access the array in reverse direction, for example-
Code:
PERFORM VARYING A1 FROM 48 BY -1......

This is not sorting but it should serve the purpose of getting the values in reverse order.

I have to replace the existing data as some other programs uses that data later.
Back to top
View user's profile Send private message
rag swain

New User


Joined: 17 Dec 2007
Posts: 33
Location: pune,INDIA

PostPosted: Tue Feb 05, 2008 10:04 pm    Post subject: Reply to: Sorting the table
Reply with quote

Try using a SORT file with INPUT PROCEDURE and OUTPUT PROCEDURE after unloading the data from the table. And ofcourse you can use subscript in stead of using index.
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 149
Location: Ottawa Canada

PostPosted: Fri Feb 22, 2008 11:18 pm    Post subject:
Reply with quote

A few months ago I posted copybooks to sort a table. Give them a try.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Sat Feb 23, 2008 2:22 am    Post subject:
Reply with quote

TG Murphy wrote:
A few months ago I posted copybooks to sort a table. Give them a try.
And here is the link for that thread...
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 Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Efficient sorting chandracdac DFSORT/ICETOOL 5 Sat Oct 22, 2016 3:23 am
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm
No new posts Stripping and Sorting of VB file G SRINIVASA RAO SYNCSORT 5 Wed Sep 14, 2016 1:34 pm


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