The way your table is defined with the fields that hold the indexes following behind it, you could easily overwrite them if you tried to load more that 200 entries in the table, which would probably trash them. Make sure that at every place in the program where entries are loaded to the table, that you test the index to make sure you don't go beyond 200. By the way, when dealing with indexes, I always use SET to modify them and I typically define index data items to save them in. You might consider moving the fields where your index is saved to a location in working storage above the table where they wouldn't get overwritten and see if you get different results. -----Original Message----- From: rick.baird@xxxxxxxxxxxxxxx [mailto:rick.baird@xxxxxxxxxxxxxxx] Sent: Thursday, June 10, 2004 3:21 PM To: cobol400-l@xxxxxxxxxxxx Subject: [COBOL400-L] RE: I'm stumped - working storage tables indexed by Also, how do you reset it to the first element in the table? In the program I'm working on, (which has worked forever) does the following types of things. 01 FILLER. 02 FILLER OCCURS 200 INDEXED BY INDEX04. 03 TBL04-INGREDIENT PIC 9(06) COMP VALUE 0. 03 TBL04-PRICE PIC 9(02)V9(04) COMP VALUE 0. 03 TBL04-MEASURE PIC X(10). 03 TBL04-DESCRIPTION PIC X(30). 02 INDEX-TBL04 PIC 9(03) COMP. 02 INDEX-TBL04-LO PIC 9(03) COMP VALUE 001. ........... load table via INDEX04, then save last index in INDEX-TBL04: SET INDEX-TBL04 TO INDEX04. then later, SET INDEX04 TO INDEX-TBL04 then later, SET INDEX04 TO INDEX-TBL04-LO still later, IF INDEX04 NOT EQUAL INDEX-TBL04 SET INDEX-TBL04-LO TO INDEX04 later still, MOVE 1 TO INDEX-TBL04-LO. in other words, saving, setting, searching, re-setting, between index fields and simple 3 digit packed fields. My problem is that at some point in the program, it gets a bad index, and moves something into my table at the wrong starting position - TBL04-INGREDIENT becomes X'0023F0F' - I've stepped through it in debug, but no matter where or how I set the breakpoint, i can't seem to catch it where it hoses the index. - it's reading through about a hundred thousand records, and i've stopped it where I think it's supposed to be changing the fields, but I keep missing. any further guidance would be appreciated. ---------original message---------------- Thanks Terry, to move the saved index back to the original, do I move or set? Rick, ---------original message------------ You can just define it like this: 05 GROUP-ITEM-LOC USAGE IS INDEX. You can now target a field defined this way in your set statement. Terry Grider -----Original Message----- From: rick.baird@xxxxxxxxxxxxxxx [mailto:rick.baird@xxxxxxxxxxxxxxx] Sent: Thursday, June 10, 2004 2:04 PM To: cobol400-l@xxxxxxxxxxxx Subject: [COBOL400-L] I'm stumped - working storage tables indexed by what type and size is an table index field? to save an index field, how what type and size of field should the result of a 'SET' verb be? can you directly compare the index field to the save field? - IF INDEX-FIELD = SAVE-INDEX-FIELD I'm having a problem with a program that's worked forever, until now - my index field is getting hammered, making a move to a table element that isn't in the bounds of the field. Thanks, Rick _______________________________________________ This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing list To post a message email: COBOL400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/cobol400-l or email: COBOL400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/cobol400-l.
As an Amazon Associate we earn from qualifying purchases.
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.