cobrix icon indicating copy to clipboard operation
cobrix copied to clipboard

How to read variable block/record mainframe data

Open syerragunta opened this issue 5 years ago • 1 comments

Background [Optional]

A clear explanation of the reason for raising the question. This gives us a better understanding of your use cases and how we might accommodate them.

Below is mainframe copy book. Which have variable record. It means some of the records will have multiple PHONE-NUMBER for given COMPANY-ID

01 COMPANY-DETAILS. 05 SEGMENT-ID PIC X(5). 05 COMPANY-ID PIC X(10). 05 STATIC-DETAILS. 10 COMPANY-NAME PIC X(15). 10 ADDRESS PIC X(25). 10 TAXPAYER. 15 TAXPAYER-TYPE PIC X(1). 15 TAXPAYER-STR PIC X(8). 15 TAXPAYER-NUM REDEFINES TAXPAYER-STR PIC 9(8) COMP. 05 CONTACTS REDEFINES STATIC-DETAILS. 10 PHONE-NUMBER PIC X(17). 10 CONTACT-PERSON PIC X(28).

Question

A clear and concise inquiry

Please can you share read syntax. when I use normal read statement. I was not able to read the data. Here is error

20/07/14 14:22:32 ERROR Executor: Exception in task 0.0 in stage 2.0 (TID 2) java.lang.IllegalStateException: RDW headers should never be zero (215,0,0,0). Found zero size record at 76.

syerragunta avatar Jul 15 '20 01:07 syerragunta

The copybook seems came from Cobrix examples. If so, it is a multi-segment variable length file. You can take a look and do test runs for this example by running this test suite: https://github.com/AbsaOSS/cobrix/blob/master/spark-cobol/src/test/scala/za/co/absa/cobrix/spark/cobol/source/integration/Test4MultisegmentSpec.scala

yruslan avatar Jul 20 '20 14:07 yruslan