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

Internal table not sorted even declaared ASEN Key and Index?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
babu_hi

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Fri May 21, 2010 11:36 am
Reply with quote

I have created internal table with some key but it is not sorted based on mentioned key,why it is not sorting?

Code:
1 WS-HOLD-VSAM-TABLE.                                           
   05 WS-SUB1                PIC 9(03) VALUE ZEROS.               
   05 WS-HOLD-DATA-REC OCCURS 1 TO 100 TIMES DEPENDING ON WS-SUB1
                           ASCENDING KEY IS WS-CAPT-DTE-HOLD     
                           INDEXED BY WS-SUB-INDEX.               
       10 WS-ACCOUNT-HOLD     PIC X(34) VALUE SPACES.             
       10 WS-AMOUNT-HOLD      PIC 9(11)V9(2) VALUE ZEROS.         
       10 WS-HLD-SQN-HOLD     PIC 9(05) VALUE ZEROS.             
       10 WS-ITEM-CNTR-HOLD   PIC 9(10) VALUE ZEROS.             
       10 WS-CAPT-DTE-HOLD    PIC 9(08) VALUE ZEROS.             
       10 WS-FLAG-HOLD        PIC X(01) VALUE SPACES. 




    PERFORM VARYING WS-SUB-INDEX FROM 1 BY 1                       
                           UNTIL WS-SUB-INDEX > WS-SUB1           
     SEARCH ALL WS-HOLD-DATA-REC                                                                     
      AT END                                                       
        DISPLAY "DATE NOT FOUND"                                   
      WHEN WS-CAPT-DTE-HOLD(WS-SUB-INDEX) = WS-LEAST-DATE         
                                                                   
        MOVE WS-HLD-SQN-HOLD(WS-SUB-INDEX) TO WS-RTI-HLD-SQN-SAVE 
        MOVE WS-AMOUNT-HOLD(WS-SUB-INDEX)  TO WS-RTI-AMOUNT-SAVE   
        MOVE 'Y' TO WS-FLAG-HOLD(WS-SUB-INDEX)                     
     END-SEARCH                                                   
    END-PERFORM.               

When i tried to use SEARCH ALL i am not getting right date? Because the table is not in sorted order.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri May 21, 2010 4:24 pm
Reply with quote

You DO realize that YOU are responsible for loading the table in ascending key order, right? Merely indicating to COBOL that your table has an ascending key does not cause COBOL to load the table in that order -- it is YOUR responsibility to ensure that the table is loaded correctly.
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
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top