Skip to main content

I am unable to understand why I am getting a 'subscript out of range' error with the following:

A 'next-record' table with 99 entries subscripted by 'bom-level':

 05 next-record occurs 99        pic S9(9) comp.    
 05 bom-level                              pic 9(2)  comp.    

I have put in debugging code and the subscript (bom-level) never breaks the 99 entry limit - in fact it never gets higher than 3 (see 'Lvl' below):

---
Enter assembly to explode...
A
<enter> to continue ...

Lvl  Ass  Comp
 1    A    B
 1    A    C
 2    C    D
 3    D    F
 3    D    G
 2    C    E
 3    E    H
 3    E    I

Object Code error : file 'partexp3'
error code: 153, pc=3C5, call=1, seg=0
153     Subscript out of range
---

My code otherwise does what it is supposed to do - it completes but I then get the error message. Can anyone throw any light on this please?

Thanks

I am unable to understand why I am getting a 'subscript out of range' error with the following:

A 'next-record' table with 99 entries subscripted by 'bom-level':

 05 next-record occurs 99        pic S9(9) comp.    
 05 bom-level                              pic 9(2)  comp.    

I have put in debugging code and the subscript (bom-level) never breaks the 99 entry limit - in fact it never gets higher than 3 (see 'Lvl' below):

---
Enter assembly to explode...
A
<enter> to continue ...

Lvl  Ass  Comp
 1    A    B
 1    A    C
 2    C    D
 3    D    F
 3    D    G
 2    C    E
 3    E    H
 3    E    I

Object Code error : file 'partexp3'
error code: 153, pc=3C5, call=1, seg=0
153     Subscript out of range
---

My code otherwise does what it is supposed to do - it completes but I then get the error message. Can anyone throw any light on this please?

Thanks

Which COBOL product and version number are you using and under what OS?

What does the statement look like on which this error occurs?

What is the exact value of bom-level at the time the error occurs?

If bom-level is a field within a file record which is being read in then perhaps you have invalid data in the file?

Thanks,


I am unable to understand why I am getting a 'subscript out of range' error with the following:

A 'next-record' table with 99 entries subscripted by 'bom-level':

 05 next-record occurs 99        pic S9(9) comp.    
 05 bom-level                              pic 9(2)  comp.    

I have put in debugging code and the subscript (bom-level) never breaks the 99 entry limit - in fact it never gets higher than 3 (see 'Lvl' below):

---
Enter assembly to explode...
A
<enter> to continue ...

Lvl  Ass  Comp
 1    A    B
 1    A    C
 2    C    D
 3    D    F
 3    D    G
 2    C    E
 3    E    H
 3    E    I

Object Code error : file 'partexp3'
error code: 153, pc=3C5, call=1, seg=0
153     Subscript out of range
---

My code otherwise does what it is supposed to do - it completes but I then get the error message. Can anyone throw any light on this please?

Thanks

>>Which COBOL product and version number are you using and under what OS?<<

Net Express 5.1, Windows XP SP3

>>What does the statement look like on which this error occurs?<<

Haven't been able to deduce this. The program produces the required output (as shown) but does not then go to the 'closing database' statements - it stops with the 'subscript out of range' message

>>What is the exact value of bom-level at the time the error occurs?<<

Based on the output, I presume 3 - the last level shown for bom-level is 3 prior to the error.

>>If bom-level is a field within a file record which is being read in then perhaps you have invalid data in the file?<<

bom-level is not a field within a file record - it is a standalone field initialized, and updated, in the program

The program uses a 'perform until bom-level = 0'  loop to create the output (bom-level is incremented/decremented in the loop) - which it successfully does - it should then go to a 'close-db' paragraph to close the database in use and execute a 'stop run' statement.. But it doesn't - it just gives the subscript error. It's also not a question of bom-level continually incrementing - another 'assembly to explode' gives a final bom-level of 1 - see below:

---
opening db...
Enter assembly to explode...
X
<enter> to continue ...

Lvl  Ass  Comp
 1    X    C
 2    C    D
 3    D    F
 3    D    G
 2    C    E
 3    E    H
 3    E    I
 1    X    Y

Object Code error : file 'partexp3'
error code: 153, pc=42D, call=1, seg=0
153     Subscript out of range
----


I am unable to understand why I am getting a 'subscript out of range' error with the following:

A 'next-record' table with 99 entries subscripted by 'bom-level':

 05 next-record occurs 99        pic S9(9) comp.    
 05 bom-level                              pic 9(2)  comp.    

I have put in debugging code and the subscript (bom-level) never breaks the 99 entry limit - in fact it never gets higher than 3 (see 'Lvl' below):

---
Enter assembly to explode...
A
<enter> to continue ...

Lvl  Ass  Comp
 1    A    B
 1    A    C
 2    C    D
 3    D    F
 3    D    G
 2    C    E
 3    E    H
 3    E    I

Object Code error : file 'partexp3'
error code: 153, pc=3C5, call=1, seg=0
153     Subscript out of range
---

My code otherwise does what it is supposed to do - it completes but I then get the error message. Can anyone throw any light on this please?

Thanks

My guess is that after the subscript is decremented to 0 and it leaves the loop it is being referenced again and the 0 subscript is causing the error.

Do you have Net Express installed on the computer on which this error is occurring?

If you do then I would recommend that you animate the program and place a breakpoint in the problem area so that you can check what the code is doing by single-stepping thru it.

If you do not have Net Express installed on this computer then I would recommend producing a core dump when the error occurs and then animating the cblcore file that is produced on a computer on which Net Express is installed and to which you have access to the source and .idy file.

You can create a core dump by executing the command cblcored prior to the execution of your program that is causing the 153 error. cblcored.exe can be found in the bin folder of the Server 5.1 product. It will ask you to select a method to use and select enable with prompt.

When the 153 error occurs it will then generate the file named cblcore into the current directory of the process.

Copy cblcore over to your development computer and in the Net Express IDE select animate and then browse to the cblcore file and select it. It will need access to your .idy file for debugging information.

This will then display your program source and the line on which the error occurred will be highlighted and you can check the contents of the programs variables.

Thanks.


I am unable to understand why I am getting a 'subscript out of range' error with the following:

A 'next-record' table with 99 entries subscripted by 'bom-level':

 05 next-record occurs 99        pic S9(9) comp.    
 05 bom-level                              pic 9(2)  comp.    

I have put in debugging code and the subscript (bom-level) never breaks the 99 entry limit - in fact it never gets higher than 3 (see 'Lvl' below):

---
Enter assembly to explode...
A
<enter> to continue ...

Lvl  Ass  Comp
 1    A    B
 1    A    C
 2    C    D
 3    D    F
 3    D    G
 2    C    E
 3    E    H
 3    E    I

Object Code error : file 'partexp3'
error code: 153, pc=3C5, call=1, seg=0
153     Subscript out of range
---

My code otherwise does what it is supposed to do - it completes but I then get the error message. Can anyone throw any light on this please?

Thanks

Chris: thanks for that. I seemed to have solved the problem. Within the 'perform until bom-level = 0' loop and, after a statement decrementing bom-level, I test for bom-level = 0 which traps this condition and allows me to leave the perform...end-perform loop to close the database gracefully. So this works.

As far as the 0 subscript being referenced again, the statements immediately after the perform...end-perform loop  (which I assume is where the program should go when bom-level = 0 in the loop)  closes down the database and ends the program, so I can't see how the subscript can be referenced again. Anyway I have an acceptable - to me - solution. Thanks again.