cobrix
cobrix copied to clipboard
CopyBook Parsing Error
Describe the bug
Getting CopyBook parsing error .
ERROR ANTLRParser: Syntax error in the copybook: Line 665:29 no viable alternative at input '01RPT-DALY-TOTL-PROM-RCRDEXTERNAL'
Code snippet that caused the issue
dfFin = spark.read.format("cobol").option("copybook", "/cobrix/copybook/copybookpath.TXT")\
.load("/cobrix/data/sourcefilevariablerecordfile")
Expected behavior
Parse copybook and source file and display results in DF
Context
- Cobrix version:cobol-parser_2.12-2.6.2.jar
- Spark version:3.1.1
- Scala version:3.1.1
- Operating system:Linux
Copybook (if possible)
02235A 01 REPORTHOLDER-DAILY-TOTAL-RECORD EXTERNAL. 02235A 05 RPT-RCRD-TYPE-ID PIC X(4). 02235A 05 RPT-RCRD-SQNC-CT PIC S9(7)V COMP-3. 05 RPT-KEY-AREA. 10 RPT-CLIENT-NUMBER PIC X(4). 06097A 10 RPT-DOR-RPT-SORT-KEY. 1.006A 15 RPT-DOR-RPT-HIERARCHY PIC X. 1.006A 15 RPT-DOR-RPT-SPA. 1.006A 20 RPT-DOR-RPT-SYSTEM PIC X(4). 1.006A 20 RPT-DOR-RPT-PRIN PIC X(4). 1.006A 20 RPT-DOR-RPT-ENTITY-3 PIC X(4). 1.006A 15 RPT-DOR-RPT-ENTITY-4 PIC 9(5). 1.006A 15 RPT-DOR-RPT-ENTITY-5 PIC 99. 1.006A 15 RPT-DOR-RPT-ENTITY-6. 1.006A 20 RPT-DOR-3-DIGIT-BOOK-CODE PIC 999. 02235A 15 FILLER PIC X(175). 10 RPT-ACCOUNT-NUMBER PIC X(8). 02235A 05 RPT-SPA.
02235A 11021A 01 RPT-DALY-TOTL-PROM-RCRD EXTERNAL PIC X(692). 02235A 02235A 01 RPT-DALY-TOTL-PROM-TABLE EXTERNAL. 02235A 05 CDT-PROM-RCRD-TYPE-ID 02235A PIC X(4). 02235A 05 CDT-PROM-RCRD-SQNC-CT PIC S9(7)V COMP-3.
Attach a small data file that can help reproduce the issue, if possible.
comments_ubound=120
Hi @sree018
I tried as you suggested with below setting , but i am getting below errors.Kindly check and help me on this please .
dfFin = spark.read.format("cobol").option("copybook", "/cobrix/copybook/copybookpath.TXT")
.option("comments_ubound", "120")
.load("/cobrix/data/sourcefilevariablerecordfile").show()
Error message :
23/01/11 06:04:16 ERROR ANTLRParser: Syntax error in the copybook: Line 665:29 no viable alternative at input '01RPT-DALY-TOTL-PROM-RCRDEXTERNAL'
Maybe this is because Cobrix parser doesn't recognize the keywork 'EXTARNAL'. Try removing it from the copybook for all fields that have it.
Hi @yruslan
I tried by removing EXTERNAL keyword in copybook , but getting below error .
ERROR ANTLRParser: Syntax error in the copybook: Line 4:37 no viable alternative at input '01REPORTHOLDER-DAILY-TOTAL-RECORDEXTERNAL'

Attached copy book for your reference . Kindly check and advice . Thanks in advance . CBExternalblog.TXT
Can you attach the copybook as a file? The one above lost all its padding and spacing.
Oh, sorry, I see you did :) will take a look
On line 4 you still have the 'EXTARNAL' keyword
