IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sorting the table


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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: 691
Location: Earth

PostPosted: Tue Feb 05, 2008 4:27 pm
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
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
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: 148
Location: Ottawa Canada

PostPosted: Fri Feb 22, 2008 11:18 pm
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

Superior Member


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

PostPosted: Sat Feb 23, 2008 2:22 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
Search our Forums:

Back to Top