Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 686
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 Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 pm
No new posts PC (UTF-8) -> z/OS (EBCDIC) -> ... prino All Other Mainframe Topics 4 Fri Sep 01, 2017 1:47 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us