cobrix icon indicating copy to clipboard operation
cobrix copied to clipboard

Length of redefined fields

Open MaksymFedorchuk opened this issue 4 years ago • 1 comments

Is it expected behavior for redefined fields to have same length as fields which they redefine? Let's say we have 07 AAA 10 BBB PIC X(06). 10 CCC PIC X(13). 07 DDD REDEFINES AAA PIC X(16).

And then in parsed schema we'll see 7 AAA r ... ... ... 19 10 BBB ... ... ... 6 10 CCC ... ... ... 13 7 DDD R ... ... ... 19

I would expect length of DDD to be 16.

MaksymFedorchuk avatar Jul 19 '21 11:07 MaksymFedorchuk

Yes, it is expected, and by design. More specifically, after parsing a copybook you have an property of the AST:

case class BinaryProperties (offset: Int, dataSize: Int, actualSize: Int)

Inside the AST both sizes are present: dataSize the size of the field as defined by the copybook, actualSize the size the field occupies in the data file. In case a field is redefined all actual sizes will be the maxiumum size of the redefined field chain, while dataSize remains reflecting field's own size.

The layout displayed in the logs reflects actualSize.

yruslan avatar Jul 20 '21 15:07 yruslan