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: 275
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
This topic is locked: you cannot edit posts or make replies. Issue in suppressing leading zeros &a... Vijay_Sirisha COBOL Programming 21 Thu Jun 07, 2018 8:01 pm
No new posts VBS to VB in COBOL and JCL srajendran2 COBOL Programming 12 Fri Jun 01, 2018 3:04 am
This topic is locked: you cannot edit posts or make replies. Rexx code to find greater then symobl... Bharath Vikraman CLIST & REXX 8 Tue May 29, 2018 9:40 am
No new posts How to convert 2 bytes into single by... pkmurali DB2 6 Fri May 25, 2018 1:41 pm
No new posts SYSADATA - COBOL - Structure displace... ganasrinivasan COBOL Programming 3 Thu May 24, 2018 9:45 pm

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