Martin Thank you for your response. I have carefully reviewed the file and have a few questions regarding handling hexadecimal numbers for the length part and how it integrates with the OCCURS DEPENDING ON clause.
Questions: The file that needs to be processed contains lengths in hexadecimal format. The length fields can be of various byte sizes: 2, 4, or 6 bytes, etc. Can we use PIC 9(2), PIC 9(4), or PIC 9(2) COMP to directly read these hexadecimal numbers and use them for the OCCURS DEPENDING ON clause? Regarding the file section: cobol Copy code FILE SECTION. FD INPUT-FILE. 01 INPUT-RECORD. How should this be written if we need to handle multiple lengths and their corresponding content using the OCCURS clause? Thank you for your assistance! Jason On Fri, 14 Jun 2024 11:00:17 +0200, Martin Trübner <[email protected]> wrote: >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 ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
