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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 153 1

Status
Not open for further replies.

carolly

Programmer
Aug 2, 2001
27
AU
I am receiving an error subscript out of range Error 153 for the following table and query.

01 REPORT-TABLE
05 CUST OCCURS 6 TIMES DEPENDING ON CUST-SUB
10 CUSTOMER
10 DAYS OCCURS 4 TIMES INDEXED BY DAYS-SUB
15 T-1-DAY PIC 9(02).
15 T-2-DAY PIC 9(02).
15 T-3-7-DAY PIC 9(02).
15 T-OVER-DAY PIC 9(02).

PERFORM VARYING CUST-SUB FROM 1 BY 1 UNTIL CUST-SUB > 6
PERFORM VARYING DAYS-SUB FROM 1 BY 1 UNTIL DAYS-SUB > 4

The customer file has 6 records and the user file has 15 records. What am I doing wrong, I have played with the size of the table but just get different error messages.
 
Carolly,

i think you took the wrong turn with that "... DEPENDING ON CUST-SUB".
That means you let the number of CUST elements depend on the value of CUST-SUB.
I get the impression you really meant to subscript those CUST elements with CUST-SUB as an index, analog to "DAYS OCCURS 4 TIMES INDEXED BY DAYS-SUB".
Changing the CUST definition to "CUST OCCURS 6 TIMES INDEXED BY CUST-SUB" should solve your problem.

If not, let us know.

Regards,
Ronald.
 
If you really need a variable-size table for the 1st level, then you have to give it a range in your OCCURS clause. I noticed that you coded:

05 CUST OCCURS 6 TIMES DEPENDING ON CUST-SUB.

You need to code it:

05 CUST-SUB PIC S9(1) COMP VALUE +6.
05 CUST OCCURS 1 TO 6 TIMES DEPENDING ON CUST-SUB

Your variable-sized table will be initialized at 6. When you do your PERFORM VARYING statement, I would first find out how large the record actually is, then move that number into CUST-SUB. Then I would code the PERFORM VARYING using a different subscript:

PERFORM VARYING SUB2 FROM 1 BY 1 UNTIL SUB2 > CUST-SUB
PERFORM VARYING DAYS-SUB FROM 1 BY 1 UNTIL DAYS-SUB > 4

The second PERFORM VARYING can stay as is, because you have defined it as a fixed-size table.

Hope this helps, Nina Too
 
RonaldB

I have changed the cust to index instead of depending on and still come up with the same error. I have even tried increasing my OCCURS for DAYS-SUB to 15 as that is the size of the incoming file but it makes no difference. The error comes up on a move statement that I am doing and I am wondering if that could be the problem. I am moving CUSTOMER-ID directly into my table i.e. MOVE CUSTOMER-ID TO CUSTOMER (CUST-SUB)
 
What is the value of CUST-SUB when you do the move? Before the PERFORM, it is unitialized. After the PERFORM, it is 7. Incidentally, I hope you have a PICTURE on CUSTOMER.

Stephen J Spiro
Member, J4 COBOL Standards Committee
check it out at

stephenjspiro at hotmail.com
 
Stephenjspiro

I have set both CUST-SUB AND DAYS-SUB TO 1 and I have a pic clause of X(04) for customer
 
Carolly,

what size is that CUSTOMER-ID (what picture) ?

Regards,
Ronald.
 
Sorry I meant to say that the pic clause for CUSTOMER
PIC X(04)
 
I'm wondering about this:

You have it set up this way:

01 REPORT-TABLE
05 CUST OCCURS 6 TIMES INDEXED BY CUST-SUB
10 CUSTOMER PIC X(04).
10 DAYS OCCURS 4 TIMES INDEXED BY DAYS-SUB
15 T-1-DAY PIC 9(02).
15 T-2-DAY PIC 9(02).
15 T-3-7-DAY PIC 9(02).
15 T-OVER-DAY PIC 9(02).

PERFORM VARYING CUST-SUB FROM 1 BY 1 UNTIL CUST-SUB > 6
PERFORM VARYING DAYS-SUB FROM 1 BY 1 UNTIL DAYS-SUB > 4


Each iteration of the PERFORM VARYING CUST-SUB, it goes and does a PERFORM VARYING of the DAYS-SUB from 1 until DAYS-SUB >4. After the 4th DAYS-SUB iteration, DAYS-SUB goes up to 5 and then the test is made to stop the DAYS-SUB iterations.

However, when DAYS-SUB goes to 5, it moves out of your subscript range. I wonder if this is what is causing your "out of range" error.

It's possible that you might have to do the PERFORM VARYING of the DAYS-SUB from 1 by 1 until DAYS-SUB greater than or equal to 4. That way, it never reaches 5 and thus never goes out of range.

You don't have to use this "greater than or equal" for the outer set of iterations (for CUST-SUB), just the inner set.

Let me know if this makes any sense at all.

Nina Too
 
In reference to my comment above, I just thought of something:

If you do your PERFORM VARYING of the DAYS-SUB from 1 by 1 until DAYS-SUB greater than or equal to 4, then you might not process the 4th iteration, as you probably would wish to.

So try this: Do the PERFORM VARYING of the DAYS-SUB from 1 by 1 until DAYS-SUB greater than or equal to 4 -- but code it with a PERFORM WITH TEST AFTER VARYING, etc. So that it will process the 4th iteration, and then after that, it will test to see if it has reached 4. Your DAYS-SUB will equal 4 (within your range), but the processing will stop before your DAYS-SUB attains a value of 5, which would put your subscript out of range.

Hope this helps, Nina Too
 
Note: If the subscript on the move of cust-sub is wrong then what the value of the rest of the sub scripts of the second occurs doesnt matter. Just comment out the second varying until the first varying is working.

If you are getting an error on the first sub script of cust-sub, then lower the number in the varying statement and see what happens.

If it compiles and runs try printing out the value of the cust-sub before you use it, by using display to send it to sending it to the display, sending it to the job control or just make a little report.

If you are reading a file with a variable length table you really must know the length of the table before you do anything. If it is a variable length table you have to determine the length and put it in a variable like table-max and use it as a test each time you load or unload the table in the varying statement.

Try it with just cust-sub before you add in the second varying statement and get cust-sub varying statement to work first. If you do not like my post feel free to point out your opinion or my errors.
 
Did you remember that all references to
DAYS
T-1-DAY
T-2-DAY
T-3-7-DAY
T-OVER-DAY
must have TWO subscripts? E.g., T-1-DAY (2,3)
or T-1-DAY (Cust-sub, days-sub) IN THAT ORDER!?


Stephen J Spiro
Member, J4 COBOL Standards Committee
check it out at

stephenjspiro at hotmail.com
 
Stephen,

good point, no doubt, but would that cause an "out of range" error ?
That one still leads me to think he's setting up his indexes too high, or maybe even too low...

Corally,

right before you do any reference to that table, DISPLAY the value of both indexes. That'll tell you what values they get, and at the time of error, what they were last.
Maybe that'll put you on the right track to solving this problem. If not, let us know what you've got.

Good luck,
Ronald.
 
If you only code 1 subscript for a data element that requires 2, then you should get a compile error. RAther than an "out of range" error message.

Nina Too
 
If the idexes are in the wrong order, you can easily get an out-of-range error.

Stephen J Spiro
 
Stephen,

now thát is a good point ! How was it again; outer table first, inner table second ?

Regards,
Ronald.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top