Jason,
try it with this (and use correct numbers- your sample had 0 to 3)
05 LL1 PIC 9(2).
05 TT1 OCCURS 0 TO 3 TIMES
DEPENDING ON LL1.
05 REMAIN PIC X(4)
and in working storage section have this:
01 TEMP-WORK.
05 LL2 PIC 9(2).
05 TT2 OCCURS 0 TO 3 TIMES
DEPENDING ON LL2.
An extra MOVE before you touch TT2.
or multiple repeats of the above
Martin
On 14.06.24 09:39, Jason Cai wrote:
Subject: Assistance Needed with COBOL File Reading Structure
Dear [Recipient's Name],
I hope this message finds you well.
I am currently working on a COBOL program to read a file with the following
format: length1, content1, length2, content2, and so on. An example of the data
in the file is as follows:
```
00F00C0000FFF00F
0110140003156011
```
I intended to use the following copybook to read the data:
```cobol
05 LL1 PIC 9(2).
05 TT1 OCCURS 1 TO 2 TIMES
DEPENDING ON LL1.
05 LL2 PIC 9(2).
05 TT2 OCCURS 1 TO 2 TIMES
DEPENDING ON LL2.
```
However, I encountered an error:
```
IGYGR1137-S "OCCURS DEPENDING ON" object "LL2" was defined in a variably
located area. Execution results are unpredictable.
```
The suggested structure to avoid this error is as follows:
```cobol
05 LL1 PIC 9(1).
05 LL2 PIC 9(1).
05 TT1 OCCURS 1 TO 2 TIMES
DEPENDING ON LL1.
10 TT11 PIC X(1).
05 TT2 OCCURS 1 TO 3 TIMES
DEPENDING ON LL2.
10 TT21 PIC X(1).
```
Unfortunately, this structure does not match the format of the file I need to
read. Could you please advise on how to correctly read a file with this
structure using COBOL?
Thank you for your any assistance !
Best regards,
Jason Cai
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN