-2

How to convert PL/I copybook to COBOL copybook.

2 PL_COPYBOOK.
  3 FIRST_FIELD   CHAR(20).
  3 SECOND_FIELD  FIXED(5).
  3 THIRD_FIELD   FIXED(9,0).
  3 FOURTH_FIELD  FIXED(7,1).
  3 FIFTH_FIELD   BIT(8).
  3 SIXTH_FIELD   FIXED BIN(15).
piet.t
  • 11,718
  • 21
  • 43
  • 52
Mohit
  • 5
  • 1

1 Answers1

5

I suggest looking each data item definition up in the PL/I documentation for the compiler you are using and translate that into the equivalent COBOL data item definition.

For example, FIRST_FIELD would be PIC X(20).

You will need to pay attention to details such as whether or not slack bytes are introduced in your data structure for alignment purposes.

cschneid
  • 10,237
  • 1
  • 28
  • 39
  • 2
    Upvoted especially for mentioning alignment. It is iportant to note that by default PL/I stuctures are ALIGNED while COBOL structures are not. With the question's copybook it is important how the level 1 item is defined - if it's not defined as UNALIGNED there will be a padding byte before SIXTH_FIELD which has to be accounted for in COBOL (e.g. by using SYNCHRONIZED). – piet.t Apr 07 '21 at 06:06
  • Is there any open source tool available to perform this conversion. – Mohit Apr 07 '21 at 18:29
  • 1
    @Mohit I am aware of no open source tools to perform this sort of conversion. – cschneid Apr 07 '21 at 19:36
  • I think it depends on the compiler version, but PL/I can work with pic as @cschneid said, then the transformation is easy! – Higinio Fuentes Nov 18 '21 at 03:28