Giter Club home page Giter Club logo

Comments (4)

Kavya1552 avatar Kavya1552 commented on September 26, 2024

@yruslan can you please provide your thoughts on this. Thanks!

from cobrix.

yruslan avatar yruslan commented on September 26, 2024

Yes, it is possible to use Cobrix specifying more than one copybook using:

.option("copybooks", "/path/to/copybook1,/path/to/copybook2,/path/to/copybook3")

This will create a layout where root GROUPs redefine each other for each copybook.

For example, if copybooks are:

    val copyBookContents1: String =
      """        01  RECORD-COPYBOOK-1.
        |           05  GROUP-1.
        |              06  FIELD-1            PIC X(10).
        |              06  FILLER             PIC X(5).
        |              06  GROUP-2.
        |                 10  NESTED-FIELD-1  PIC 9(10).
        |                 10  FILLER          PIC 9(5).
        |""".stripMargin
    val copyBookContents2: String =
      """        01  RECORD-COPYBOOK-2A.
        |           05  GROUP-1.
        |              06  FIELD-1            PIC X(20).
        |              06  FILLER             PIC X(10).
        |              06  GROUP-2.
        |                 10  NESTED-FIELD-1  PIC 9(20).
        |                 10  FILLER          PIC 9(10).
        |        01  RECORD-COPYBOOK-2B REDEFINES RECORD-COPYBOOK-2A.
        |           05  GROUP-1.
        |              06  FIELD-1            PIC X(20).
        |              06  FILLER             PIC X(10).
        |              06  GROUP-2.
        |                 10  NESTED-FIELD-1  PIC 9(20).
        |                 10  FILLER          PIC 9(10).
        |""".stripMargin
    val copyBookContents3: String =
      """        01  RECORD-COPYBOOK-3.
        |           05  GROUP-1.
        |              06  FIELD-1            PIC X(30).
        |              06  FILLER             PIC X(15).
        |              06  GROUP-2.
        |                 10  NESTED-FIELD-1  PIC 9(30).
        |                 10  FILLER          PIC 9(15).
        |""".stripMargin

The merged copybook layout will be:

-------- FIELD LEVEL/NAME --------- --ATTRIBS--    FLD  START     END  LENGTH

1 RECORD_COPYBOOK_1                    r              1      1     90     90
  5 GROUP_1                                           2      1     30     30
    6 FIELD_1                                         3      1     10     10
    6 FILLER                                          4     11     15      5
    6 GROUP_2                                         5     16     30     15
      10 NESTED_FIELD_1                               6     16     25     10
      10 FILLER                                       7     26     30      5
1 RECORD_COPYBOOK_2A                   rR             8      1     90     90
  5 GROUP_1                                           9      1     60     60
    6 FIELD_1                                        10      1     20     20
    6 FILLER                                         11     21     30     10
    6 GROUP_2                                        12     31     60     30
      10 NESTED_FIELD_1                              13     31     50     20
      10 FILLER                                      14     51     60     10
1 RECORD_COPYBOOK_2B                   rR            15      1     90     90
  5 GROUP_1                                          16      1     60     60
    6 FIELD_1                                        17      1     20     20
    6 FILLER                                         18     21     30     10
    6 GROUP_2                                        19     31     60     30
      10 NESTED_FIELD_1                              20     31     50     20
      10 FILLER                                      21     51     60     10
1 RECORD_COPYBOOK_3                    R             22      1     90     90
  5 GROUP_1                                          23      1     90     90
    6 FIELD_1                                        24      1     30     30
    6 FILLER                                         25     31     45     15
    6 GROUP_2                                        26     46     90     45
      10 NESTED_FIELD_1                              27     46     75     30
      10 FILLER                                      28     76     90     15

I usually prefer to combine copybooks manually so I have more control on which fields are part of every segment, and which are different for each segment.

from cobrix.

Kavya1552 avatar Kavya1552 commented on September 26, 2024

@yruslan Thanks for your reply. In my case there are multiple record types defined in single copybook. So, do you think this ".option("copybooks", "/path/to/copybook1,/path/to/copybook2,/path/to/copybook3")" works?

from cobrix.

yruslan avatar yruslan commented on September 26, 2024

The "copybooks" options is specifically designed for the situation of multiple record types. And it works for our use cases.

from cobrix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.