I am trying to read a single copybook that represents multiple records in a ASCII file output. I am new to cobol and have been trying to parse the copybook in RecordEditor to generate the Java code. I can successfully load the copybook under Utilities -> Cobol Copybook Anaylsis. When I try import the copybook using "Load Cobol Record Layout" I get String index out of range: 0 error.
I need some guidance if the format and structure of copybook is valid and also if the file structure is correct to read/parse the data file.
Below is the actual data file definition and structure documentation:
Bruce. Thanks for your prompt reply. Commenting that line out worked. However when you open the data file the encoding seems to be ASCII. So will there still be corruption with the comp field ? What is your recommendation to handle the comp field in the ASCII data file to avoid such corruption or incorrect parsing of the file.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can certainly view/edit the file with file with the RecordEditor but remember
If the file was converted from the Mainframe this field could be corrupt
Lines could be split in 2 if a \n happens to be in this field
From the Mainframe
When transferring a binary file from the Mainframe
Use the binary transfer option (keep the file as EBCDIC)
For VB files also use the RDW option is used to ensure the RDW is transferred
Note: RDW: record Descriptor word basically record length
Note: VB Files are a type of file on the mainframe. Each Record has a RDW (basically record length) preceding it.
It is important that this RDW is also transferred
Problems with doing a EBCDIC to ASCII translation of a binary file
The translation program will treat binary fields as text fields as text fielk. So if
a boinary field has x'40' (64 decimal) the EBCDIC space character it will be converted to
the ASCII space character x'20' (Decimal 32). So your 64 is now 32
COBOL on the PC / linux / unix
If you are using COBOL on a PC / Linux etc you can use ASCII but for binary files Do not use Standard Text files (LINE SEQUENTIAL in COBOL) use either Fixed length or variable length.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It seems the get fieldValue is including the RRC-TAPE-RECORD-ID value and concatenating it with Lat/Long fields. Can you please advise why this might be happening.
Last edit: Amer Safdar 2023-04-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem is the Copybook does not match the data. So either it is the wrong file or the wrong copybook.
I reliase this not something you can influence, one of the things I have always advacate is including the copybook name in the file name at specified position (start or end). It makes life easy for everybody !!! e.g. if the copybook is PZR1000, the file name might be (ptpz.PZR1000.price.extract or ptpz.price.extract.PZR1000)
There is no way to do this in JRecord. It would have to be handled in program logic.
It is not something Cobol does, it would be handled in the cobol Code.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks @bruce_a_martin are you able to share what the code might look like ? How will I determine the end of the string here ? Can P0000000000 be treated as newline character ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The SEQUENCE-NUMBER is quite possibly the answer. I was going to say I need to see more of the file. Cobol copybooks do not tell you things like this, it is held in the Cobol Code, but you can generally work it out provided you can see enough of the file to see any patterns
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am trying to read a single copybook that represents multiple records in a ASCII file output. I am new to cobol and have been trying to parse the copybook in RecordEditor to generate the Java code. I can successfully load the copybook under Utilities -> Cobol Copybook Anaylsis. When I try import the copybook using "Load Cobol Record Layout" I get String index out of range: 0 error.
I need some guidance if the format and structure of copybook is valid and also if the file structure is correct to read/parse the data file.
Below is the actual data file definition and structure documentation:
https://www.rrc.texas.gov/media/zgccdjpi/drillingpermitmasterpluslatitudeslongitudes_oga049m_july1.pdf
I have attached the data file, extracted copybook from PDF and the error message I am receiving in record edit.
Thank you.
The problem is with field RAILROAD-COMMISSION-TAPE-REC, it has no picture clause:
Just comment it out, I will update RecordEditor to report/ignore this type of issue.
Also a separate issue is DA-CONVERTED-DATE is a comp field. This create 2 problems:
Last edit: Bruce Martin 2022-12-22
Bruce. Thanks for your prompt reply. Commenting that line out worked. However when you open the data file the encoding seems to be ASCII. So will there still be corruption with the comp field ? What is your recommendation to handle the comp field in the ASCII data file to avoid such corruption or incorrect parsing of the file.
You can certainly view/edit the file with file with the RecordEditor but remember
From the Mainframe
When transferring a binary file from the Mainframe
Note: RDW: record Descriptor word basically record length
Note: VB Files are a type of file on the mainframe. Each Record has a RDW (basically record length) preceding it.
It is important that this RDW is also transferred
Problems with doing a EBCDIC to ASCII translation of a binary file
The translation program will treat binary fields as text fields as text fielk. So if
a boinary field has x'40' (64 decimal) the EBCDIC space character it will be converted to
the ASCII space character x'20' (Decimal 32). So your 64 is now 32
COBOL on the PC / linux / unix
If you are using COBOL on a PC / Linux etc you can use ASCII but for binary files
Do not use Standard Text files (LINE SEQUENTIAL in COBOL) use either Fixed length or variable length.
Hi @bruce_a_martin
I have managed to generate Java code to read and extract the records. I have an issue with following section:
Record number 14 and 15 have latitude and longitude values that represent in the data file like this:
14 -94.3251710 31.4884060
15 -94.3185210 31.4729580
But when i extract the values, using Java code, they are coming out like this:
This is my code:
It seems the get fieldValue is including the RRC-TAPE-RECORD-ID value and concatenating it with Lat/Long fields. Can you please advise why this might be happening.
Last edit: Amer Safdar 2023-04-14
The problem is the Copybook does not match the data. So either it is the wrong file or the wrong copybook.
I reliase this not something you can influence, one of the things I have always advacate is including the copybook name in the file name at specified position (start or end). It makes life easy for everybody !!! e.g. if the copybook is PZR1000, the file name might be (ptpz.PZR1000.price.extract or ptpz.price.extract.PZR1000)
In this case, the Copybook should look like:
I updated the CopyBook file section to below and it worked. Thanks:
Hi @bruce_a_martin in the copybook file I have lots filler entries like below
I noticed the DA-REMARK-LINE field is getting cutoff. its a long string but separated by new line.
Example:
How can I get whole string ?
Thanks.
There is no way to do this in JRecord. It would have to be handled in program logic.
It is not something Cobol does, it would be handled in the cobol Code.
Thanks @bruce_a_martin are you able to share what the code might look like ? How will I determine the end of the string here ? Can P0000000000 be treated as newline character ?
I noticed the SEQUENCE-NUMBER defines if there is a records continuation from previous number
The SEQUENCE-NUMBER is quite possibly the answer. I was going to say I need to see more of the file. Cobol copybooks do not tell you things like this, it is held in the Cobol Code, but you can generally work it out provided you can see enough of the file to see any patterns