Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SETLL AND READE

Status
Not open for further replies.

rstitzel

MIS
Apr 24, 2002
286
US
I have a order detail file that i'm retrieving records from. I have a klist named speckey and it's made up of three fields Customer Number, Block Number and Order Number. The file itself has four key fields Customer Number, Block Number, Order Number and Product Number.

I use the following code to position the file:
c speckey setll specd

I then use this code to read the records
c speckey reade specd

I loop through the file and retrieve the matched records and write it to a display file. And it works. The only problem I have is that the records come back sorted in ascending key order. I don't want any sorting. I just want it to read the records as they are found in the file.

Does anyone know how to accomplish this?

Thanks in advance for any and all help.
 
rstitzel:

"Array index out of range" means that you have more data than the array can handle.

Change the DIM statement on the array. I was just using 100 elements as an example. How many records are you pulling? Might want to ramp that array up to 1000 or so, depending on what you think the max number of records your selection retrieves. Make sure you change the size of the index also, from a 3S 0 to a 4S 0. Make sense?

RedMage1967
IBM Certifed - RPG IV Progammer
 
That's what I thought was causing the problem but I looked at the file and it has a TOTAL of 46 records right now. But I went ahead and changed it to 10000 (there'll be a lot of records in this file when it's in production), 5S 0 and am getting the same error! Any other suggestions?
 
At what statement are you getting the error at? Loading the array, or skipping past the cells with zero in them, after the SORTA?

RedMage1967
IBM Certifed - RPG IV Progammer
 
I went over the code over and over and finally see what was happening. If you look at the example you provided in the first set of code the do while loop is missing a read in there.

The code:
dow not %eof(specdv1r)
a = a+1;
datarrn(a) = rrnlf1;
enddo

no read so it never got to the eof and just incremented the A counter.

Took me a little while to finally see that :) I'm now getting another error but I think I can handle that one :) If not I'll post something on the board.

Thanks again for your help.
 
Ooops, sorry about that. Glad you were able to find it and fix it.

RedMage1967
IBM Certifed - RPG IV Progammer
 
yeah, that's it. Wanted to see how good at debugging you were. yeah, yeah..................

:)
;)

RedMage1967
IBM Certifed - RPG IV Progammer
 
I'm back! Sorry. After all that I run the program and get the exact same results as before the change. I know it's probably the way I have the file set up. Please tell me what I'm doing wrong here:

The physical file has four keys CustNum, BlockNum, SpecNum, ProductNum

The logical file has four keys the same as above

The klist I'm using only has three keys CustNum, BlockNum and SpecNum.

So should the logical file be keyed and NOT the physical file or vise versa.....? :)

Thanks
 
The logical should be keyed.

does your code look like this:
Code:
SetLl Keys Logical;
If %Equal(Logical);
  ReadE Keys Logical;
  Index = 0;
  DoW Not %EoF(Logical);
    Index = Index + 1;
    ArrayRrn(Index) = Rrn;
    ReadE Keys Logical;
  EndDo;
EndIf;

What is debug telling you?


RedMage1967
IBM Certifed - RPG IV Progammer
 
YES

C SPECKEY SETLL
C IF %EQUAL(SPECDV1)
C SPECKEY READE SPECDV1
C EVAL A =0
C DOW NOT %EOF(SPECDV1)
C EVAL A =A+1
C EVAL DATARRN(A) =RRNLF1
C SPECKEY READE SPECDV1
C ENDDO
C ENDIF
 
You said the logical should be keyed. I have the physical file set up with keys to....should I remove them?
 
The only thing I see is that you didn't specify a record or file name on you SETLL. The pf can have keys, so long as in your 'F' spec the address type if blank. (not sure what column nbr that is, column 34, I think).

Your in Portland, OR, right???
five zero three four four five three two five seven.

RedMage1967
IBM Certifed - RPG IV Progammer
 
REDMAGE1967:

SORRY...IT'S WORKING NOW!! DIDN'T CHANGE ANYTHING EXCEPT THAT I CLEARED THE FILE AND THEN ENTERED SOME ORDERS AND RAN THE PROGRAM YOU HELPED ME WITH AND IT'S NOW COMING UP IN THE ORDER THAT IT WAS WRITTEN.

THANK YOU VERY MUCH FOR ALL YOUR HELP ON THIS MATTER!!!

ROBERT
 
Cool. Glad it's working the way your wanted it to. Glad to be of help.

RedMage1967
IBM Certifed - RPG IV Progammer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top