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: 8165
Location: East Dubuque, Illinois, 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 Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 pm
No new posts PC (UTF-8) -> z/OS (EBCDIC) -> ... prino All Other Mainframe Topics 4 Fri Sep 01, 2017 1:47 am

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