AbsaOSS/cobrix

Support for decimal scaling PV

rjethure opened this issue · 6 comments

Describe the bug

Cobrix should support the decimal scaling of character PV in copybook, getting error for S9(7)PPPV.
For usage click here

Expected behavior

It should parse the copybook file. Without below error:

ERROR ANTLRParser: Syntax error in the copybook: Line  no viable alternative at input XXXX:XX 'S9(7)PPPV'
Caused by: za.co.absa.cobrix.cobol.parser.exceptions.SyntaxErrorException: Syntax error in the copybook at line XXXX: Invalid input 'V' at position XXXX:XX

Copybook (if possible)

 05  Parent-Column                  COMP-3.              
     07  Child-1   PIC S9V99.                           
     07  Child-2   PIC S9(7)PPPV.                       
     07  Child-3   PIC S9V99.                           
     07  Child-4   PIC S9(7)PPPV.                       
     07  Child-5   PIC S9(7)PPPV.                       
     07  Child-6   PIC S9(7)PPPV.                       
     07  Child-7   PIC S9(7)PPPV.                       
     07  Child-8   PIC S999.                            
     07  Child-9   PIC S9(11).                          

Hi @rjethure ,

Cobrix already supports integer and decimal scaling. It just does not support implicit comma 'V' at the and of the PIC. Please, try removing 'V' and let know if the behavior is as expected.

Hi @yruslan,

Thank you for quick response.
I tried by removing 'V' from copybook. After removing 'V' copybook is getting parsed without error.

But input data file's column are not getting correctly parsed. I am suspecting it is messing with START and END indices of the columns.

How exactly data is not correctly parsed? What is the expected and actual output?
You can use layout positions output from logs to determine if start and end offsets as as expected. Also you can use .option("debug", "true") to see raw values being decoded to spot mismatches.

Is it sorted?

The support for PIC S9(7)PPPV is implemented and now is in the master branch. The logic is the same as for PIC S9(7)PPP, according to this:
https://knowledge.informatica.com/s/article/109965?language=en_US

The feature is available in spark-cobol:2.7.0