Reading Cobol File using CFF Stage

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
bikan
Premium Member
Premium Member
Posts: 128
Joined: Thu Jun 08, 2006 5:27 am

Reading Cobol File using CFF Stage

Post by bikan »

Hi Friends,

I was trying to read through a Cobol File which has a occur clause in it. I tried to read data using the complex flat file stage.

I am able to read the file however datastage is not able to filter the group according to the occur clause.

Ex.

05 FIELD-A PIC X(4)
05 FIELD-E PIC 9(02)
05 FIELD-B OCCURS 0-5 TIMES depending on the value of E
10 FIELD-C PIC X(4)
10 FIELD-D PIC X(4)

In this example I want datastage to read the value of field E and repeat the group B as many times as its value.

If the value of E is ZERO(0)

The reading of the file should be like

FIELD-A, FIELD-E (Group B does not occur as E is 0)

If the value of E is One(1)
The reading of the file should be like

FIELD-A,FIELD-E,FIELD-C,FIELD-D

If the value of E is Two(2)
The reading of the file should be like

FIELD-A,FIELD-E,FIELD-C,FIELD-D,FIELD-C_1,FIELD-D_1

And so on...!

However I am not able to achieve this even after specifying the occurs depending on clause in the stage properties.

Kindly, Help...!!!

Thanks
Ramesh
kris
Participant
Posts: 160
Joined: Tue Dec 09, 2003 2:45 pm
Location: virginia, usa

Re: Reading Cobol File using CFF Stage

Post by kris »

bikan wrote:I was trying to read through a Cobol File which has a occur clause in it. I tried to read data using the complex flat file stage.

I am able to read the file however datastage is not able to filter the group according to the occur clause.
Ramesh
Make sure you have the right file definition (copy book).

complex flat file stage will extract data based on your metadata definition which happen to be a copy book in this case.

Important column is Level number, which represents the level number of the column within a COBOL file description.

If you can not figure out, give more information like exact metadata definitions and the errors.

Kris~
~Kris
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Complex Flat File Usage

Post by asorrell »

I've used the CFF stage frequently, and found it is easiest to setup if you do the following:

1) Get the cobol copybook (note what column the level #'s are in)

2) Right-click on Table Definitions and select Import COBOL definitions.
- Put the path to the copybook and the start column for level #'s.
- Hit Import

3) Go to the CFF stage Input Columns and the load the columns from the table definitions.

That seems to keep everything straight...

If you continue having problems please post the copybook in your next response.
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Does not the manual state that OCCURS DEPENDING ON is not supported in versions 7.5 and earlier?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
bikan
Premium Member
Premium Member
Posts: 128
Joined: Thu Jun 08, 2006 5:27 am

Post by bikan »

Thanks a ton Ray..!!!

I guess that is where the problem lies.

Thanks

Ramesh
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

With such a simple layout, you could read this as a single VarChar field (using a Sequential File stage) and parse it in a Transformer stage, flattening the repeating group into separate columns. Whether or not you keep E is rather irrelevant - you simply parse into five pairs of columns, perhaps substituting @NULL for "".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply