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
 
Internal table not sorted even declaared ASEN Key and Index?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Internal table not sorted even declaared ASEN Key and Index?
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: 8279
Location: Dubuque, Iowa, USA

PostPosted: Fri May 21, 2010 4:24 pm    Post subject:
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    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 IDCAMS RENAMING VSAM FILE ALONG WITH ... upendrasri JCL & VSAM 11 Tue Apr 17, 2018 10:42 pm
No new posts Searching a table for the field name? socker_dad COBOL Programming 8 Sat Mar 31, 2018 2:57 am
No new posts Need inputs on DB2 tablespace/table r... ashek15 DB2 3 Sat Mar 24, 2018 11:49 pm
No new posts COBOL declaration for table Poha Eater DB2 3 Mon Feb 26, 2018 6:58 pm
No new posts load and delete table through JCL wit... ram_vizag JCL & VSAM 9 Thu Feb 01, 2018 12:47 am

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