Page 1 of 1

How to create COBOL file with OCCURS clause?

Posted: Mon Nov 26, 2018 11:46 pm
by gv.subash
Hi,

I need to convert .csv file data to COBOL copybook format. I designed different jobs for header, detail and the trailer, and one other job to combine all these.

But, I have a scenario where there is an OCCURS clause (occurs 70 times). How to pass data in such scenario?

For example: Name, ID, Add1, Add2,Add3, Add4
Input file: venkat, 10, India, USA, Mexico, spain.

My output should be:
Venkat10IndiaVenkat10USAVenkat10MexicoVenkat10Spain

Could you please help me achieve this?

Thank you
Venkat

Posted: Tue Nov 27, 2018 6:40 am
by chulett
So... you can get up to 70 of these "Add" fields? Or is it always 70? And you need to repeat the ID and concatenate these together into one long string?

If so, what have you tried so far? If not, please clarify the requirements.

Posted: Tue Nov 27, 2018 10:54 am
by FranklinE
I suppose a transformer loop would be a good approach. You need to do several things here.

You have to know how many instances of the OCCURS you need to use for each input row. Will it always be the same number?

Is there a direct link between the number of address columns in the .csv file and the output copybook? For example, are there 70 columns for addresses, with the ones not containing a valid address spaces, empty or null?

In general, the first requirement of a COBOL format record is that all fields contain valid values, whether usable data or defaults or just something to fill the space.

Posted: Tue Nov 27, 2018 11:46 am
by chulett
FranklinE wrote:I suppose a transformer loop would be a good approach.
Was thinking the same thing.

Posted: Tue Nov 27, 2018 3:59 pm
by ray.wurlod
You might also investigate using the extended properties to define a vector, and use functionality such as the Make Vector stage.

Posted: Tue Nov 27, 2018 6:25 pm
by chulett
Oooo... interesting. Choose your own adventure!

The path forks ahead, where you can see a newly painted sign. To the right, the well-trodden path you've been following continues. To the left, a smaller trail branches off into the wilderness. You pause to read the sign, which asks you to consider taking the path less travelled to seek new adventures.

Which path do you chose?

:D