Page 1 of 1

Reading Cobol File using CFF Stage

Posted: Thu May 03, 2007 5:27 am
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

Re: Reading Cobol File using CFF Stage

Posted: Thu May 03, 2007 12:36 pm
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~

Complex Flat File Usage

Posted: Thu May 03, 2007 3:51 pm
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.

Posted: Thu May 03, 2007 4:36 pm
by ray.wurlod
Does not the manual state that OCCURS DEPENDING ON is not supported in versions 7.5 and earlier?

Posted: Fri May 04, 2007 12:03 am
by bikan
Thanks a ton Ray..!!!

I guess that is where the problem lies.

Thanks

Ramesh

Posted: Fri May 04, 2007 2:20 am
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 "".