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

Sorting an array with three different keys


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

Moderator Emeritus


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

PostPosted: Sun Sep 30, 2007 8:39 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
No new posts Use input file with OMIT rcd keys? DFSORT/ICETOOL 15
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts Sorting a record spanned over multipl... DFSORT/ICETOOL 13
No new posts To find an array of words (sys-symbol... JCL & VSAM 9
Search our Forums:

Back to Top