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: 256
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 SORT BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm
No new posts Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts JOINKEYS Paired and Unpaired Sort on ... MFwhiz DFSORT/ICETOOL 7 Tue Nov 07, 2017 2:46 am

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