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
 
Table sort in cobol

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

New User


Joined: 30 Jun 2005
Posts: 1

PostPosted: Thu Jun 30, 2005 4:41 am    Post subject: Table sort in cobol
Reply with quote

The working storage section is:
05 WS-INFO OCCURS 103 TIMES
INDEXED BY A1.
10 PROD-D1 PIC X(15).
10 CASH-2 PIC S9(05)V99 COMP-3.
10 CASH-REFUND PIC S9(05)V99 COMP-3.
10 CASH-NET PIC S9(05)V99 COMP-3.
:
:
I want to sort the WS-INFO is to be sorted in ascending sequence based on PROD-D1 field from 4th occurrence to 103rd occurrence.
Could you please suggest how to implement in the program. I want full code.
Back to top
View user's profile Send private message

mdtendulkar

Active User


Joined: 29 Jul 2003
Posts: 238
Location: USA

PostPosted: Tue Aug 09, 2005 5:19 am    Post subject: Re: Table sort in cobol
Reply with quote

prashanthkumar_hs,

How about referring this link and come up with the logic you desired?
Following link will give you a similar code as per your requiremnt.

http://home.att.net/~arnold.trembley/svalgard.htm

Hope this helps,

Regards
Mayuresh
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 252
Location: Cincinnati OH USA

PostPosted: Tue Aug 09, 2005 8:18 am    Post subject:
Reply with quote

Just use COBOL's SORT verb with input and output procedures to give records (table entries) to SORT and reload table upon SORT returning those records.


Dave
Back to top
View user's profile Send private message
fixdoubts

New User


Joined: 21 Oct 2005
Posts: 54

PostPosted: Thu Nov 24, 2005 5:47 pm    Post subject: Re: Table sort in cobol
Reply with quote

PERFORM
VARYING X FROM 4 BY 1 UNTIL X > 101

COMPUTE Y = 101 - X

PERFORM
VARYING Z FROM 4 BY 1 UNTIL Z > Y

MOVE PROD-P1(Z) TO TEMP1
MOVE PROD-P1(Z+1) TO TEMP2

IF ( TEMP1 > TEMP2)
INTERCHANGE THE TABLE ENTRIES FOR Z AND Z+1
ELSE
CONTINUE
END-IF
END-PERFORM
END-PERFORM

THIS MIGHT HELP

REGARDS,
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 Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 4 Fri Sep 22, 2017 4:56 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 OC4 in SORT Mohan Kothakota DFSORT/ICETOOL 2 Tue Sep 12, 2017 6:30 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am

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