View previous topic :: View next topic |
Author |
Message |
Chandru Beginner
Joined: 18 May 2004 Posts: 6 Topics: 6
|
Posted: Thu Jul 01, 2004 9:52 am Post subject: sorting a table ?? |
|
|
Hi friends,
Is there any easiest method to sort a table? Help me .
chandru. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Thu Jul 01, 2004 10:10 am Post subject: |
|
|
Chandru,
Here is a sample code to sort a table.
Code: |
01 W-FEE-TBL.
02 FEES-TABLE OCCURS 30 TIMES DEPENDING ON T-COUNT.
03 FEES-REC.
04 FEE-TYPE PIC X.
04 FILLER PIC X.
04 FEE-BAL PIC 9(05)V99.
01 W-SUB PIC S9(9) COMP.
01 W-SUB1 PIC S9(9) COMP.
01 W-SUB2 PIC S9(9) COMP.
01 W-TMP-REC PIC X(09).
01 T-COUNT PIC S9(9) COMP.
PROCEDURE DIVISION.
PERFORM VARYING W-SUB1 FROM 1 BY 1 UNTIL W-SUB1 >= T-COUNT
PERFORM VARYING W-SUB2 FROM T-COUNT BY -1
UNTIL W-SUB2 <= W-SUB1
EVALUATE TRUE
WHEN FEE-TYPE (W-SUB2) < FEE-TYPE (W-SUB2 - 1)
MOVE FEES-REC (W-SUB2) TO W-TMP-REC
MOVE FEES-REC (W-SUB2 - 1) TO
FEES-REC (W-SUB2)
MOVE W-TMP-REC TO FEES-REC (W-SUB2 - 1)
WHEN FEE-TYPE (W-SUB2) > FEE-TYPE (W-SUB2 - 1)
CONTINUE
END-EVALUATE
END-PERFORM
END-PERFORM
.
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|