Skip to main content

Digital Experience

Fixing COBOL layout issues using DFDL LPEX Editor

Introduction:

In general for message modeling COBOL  copybook layouts we use the DFDL parser within IBM Integration Bus Toolkit  to model and generate the DFDL schema . In some cases we find COBOL layout errors in generating the message model.

We might think that once a COBOL  copybook is defined in the mainframe environment and is working why would it error out ?

One of the main reasons it could happen is a COBOL  layout defined within the COBOL program itself under working storage section.

So if there is a business use case to model these kind of COBOL  layouts as DFDL schemas what we do is ask the mainframe person to do a cut and paste of the COBOL   layout in a notepad and send it across.

But in doing so there is a chance that the layout alignment might get disrupted even though the syntax of the layout in the source COBOL  program is correct.

COBOL compiler has a restriction on how the layout is defined. Few of the positional restrictions are COMMENTS in the layout should be on only on 7th column and  “01 clause” should start from “A section” which is from 8th column onwards and many more. Basically in mainframe environment COBOL  compiler will throw these errors so that the developer will fix.

So to handle the above COBOL  layout issues I noticed that we could make use of “Basic LPEX Editor” within IBM Integration Bus Toolkit which mimics the same functionality of what a COBOL  compiler does.

Objective :

Illustrate the steps on how to fix the COBOL  copybook layout issue using “Basic LPEX Editor” of IBM Integration Bus Toolkit.

 

Steps:-

( Please make sure that COBOL  copybook layout has an extension of “.cpy” otherwise DFDL will throw errors. )

Recreate the COBOL  layout issues:

1. We will recreate the issue by using a COBOL  layout which has positional errors. For testing purpose I have intentionally changed the COBOL  layout and this is how it looks. Name of the file is  “ReginaCARecord.cpy”.

COBOL Copybook Layout-PositionalError

2. Copy the “ReginaCARecord.cpy” file into IIB workspace.

3. Right click on the  “ReginaCARecord.cpy” file and select New – Message Model . Click Next until you see the following errors.

COBOL Copybook Errors

 

How to fix the above issue:

1. Open the COBOL  copybook “ReginaCARecord.cpy” using “Basic LPEX Editor”

LPEX Editor View of cpy

2. Following is the error you will notice which means the COBOL  layout has positional errors.

LPEX Editor-Error

3. From the above error it says that “0 is not valid in indicator area” which makes no sense to us but if you look at the red  ‘x’ to the left hand side tool tip says the following which means the compiler is expecting only  ‘*’ on column 7 . Then I realized that 01 clause should start from 8th column onwards.

COBOL Copybook Error SnapShot

4.So we need to adjust the “ReginaCARecord.cpy” file to align the position of  “01 clause”  to 8th column  based on the above error. So we need to open the same file in a text editor mode.

Text View of cpy

5. This is how both the “Text Editor” and LPEX Editor views look like on the right hand side and you can switch between views easily without having to reopen them again and again.

( Note :Please  do not close these editors once opened but only switch ). 

LPEX Editor-Switch

6. Fix the positional error by manually moving the “01 clause to the 8th column in the “Text Editor” View only , save it ( Ctrl+S) and then switch back to the “LPEX Editor” View to see if the errors are fixed.

LPEX Editor-Success

7. Now you can repeat the same steps 5 through 6 to fix all the possible errors in the layout by switching between Text and LPEX Editor views.

8. Now the DFDL model schema will be successfully generated after right clicking on the “ReginaCARecord.cpy” file and selecting “New — Message Model”  without any issues.

 

Possible list of COBOL layout errors captured within IBM Integration Bus Toolkit :

COBOL Copybook - ErrorList

 

Summary:

Before even trying to generate the DFDL schema for COBOL  copybook layouts please try to do the following.

  1. Make sure the COBOL  copybook layout file has .cpy extension
  2. Copy the .cpy file to your IBM Integration Bus ( IIB )  Toolkit  workspace
  3. Open it using Basic LPEX Editor to see if the layout has any errors.
  4. If any errors found don’t panic you can use the above method mentioned to fix the errors and then generate the DFDL schemas out of COBOL  copybooks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.