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 an array with three different keys

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

New User


Joined: 11 Aug 2005
Posts: 45
Location: India

PostPosted: Sun Sep 30, 2007 6:27 am    Post subject: Sorting an array with three different keys
Reply with quote

Hi friends,

I have defined an array in the program like this

01 WS-PENDING-TABLE.
05 WS-PD-ENTRIES OCCURS 1800 TIMES
INDEXED BY PD-IX.
10 WS-PD-ENTRY.
15 WS-PD-PARENT-ITEM PIC X(3).
15 WS-PD-MNSTRUSG.
20 WS-PD-COMP PIC X(3).
20 WS-PD-STRT-EA PIC X(2).
15 WS-PD-MNRELTSG.
20 WS-PD-REL-COMP PIC X(3).
20 WS-PD-REL-STRT-EA PIC X(2).


The array contains the following data

234222XX235YY
234222XX123YY
234222XX123YY
234111XX555YY
234111XX333YY
123999XX234YY
123999XX123YY
123888XX555YY
123888XX333YY
.....
....
....

My requirement is, I have to sort the array first on WS-PD-PARENT-ITEM then on WS-PD-COMP and then on WS-PD-REL-COMP so that the array is in the sorted order as shown below

123888XX333YY
123888XX555YY
123999XX123YY
123999XX234YY
234111XX333YY
234111XX555YY
234222XX123YY
234222XX123YY
234222XX235YY


Also i need to have the sorted data in the same array.

Can you please help me in writing this logic


Thanks in advance
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Sep 30, 2007 8:39 am    Post subject:
Reply with quote

Hello,

If you think of the requirement having 3 keys, you make it more difficult. It is your program, so you can define the table so that all of the "key" info is contiguous.

Where are you getting the data to put into this array? If the data is read from an external file, you can sort the array data before reading it in your code and moving it into the array.

For up to 1800 entries, i'd suggest using SEARCH ALL to reduce the cpu cycles needed.

When you've read this and continued with your code, post any questions you have here and someone will be able to help.
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 Efficient sorting chandracdac DFSORT/ICETOOL 5 Sat Oct 22, 2016 3:23 am
No new posts Joinkeys with duplicated keys juares castro SYNCSORT 19 Fri Sep 23, 2016 5:58 am
No new posts Stripping and Sorting of VB file G SRINIVASA RAO SYNCSORT 5 Wed Sep 14, 2016 1:34 pm
No new posts DFSORT sorting only specific records akodakka DFSORT/ICETOOL 4 Thu Aug 04, 2016 11:24 am
No new posts Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm


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