IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Dynamic Definition of a data record in the file section


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
minino

New User


Joined: 15 Nov 2005
Posts: 5

PostPosted: Tue Jan 17, 2006 7:01 pm
Reply with quote

Hi,

I am trying to write a COBOL program, which will be able to receive 2 input files (sequential) and produce 1 output. The input files are unknown at compilation time, therefore I need to:

1. Define the files in the file section with a data record that has no PICTURE or can get its record length dynamically at run-time.

2. Dynamically allocate the output file since its record length depends on the input data. regarding this issue I saw some responds in the forum but not quite understood them.

Is it possible to do such a program?

Many thanks,

Rotem
Back to top
View user's profile Send private message
gowtham_1982
Warnings : 1

Active User


Joined: 02 Dec 2005
Posts: 109

PostPosted: Wed Jan 18, 2006 10:21 am
Reply with quote

minino wrote:
Hi,

I am trying to write a COBOL program, which will be able to receive 2 input files (sequential) and produce 1 output. The input files are unknown at compilation time, therefore I need to:

1. Define the files in the file section with a data record that has no PICTURE or can get its record length dynamically at run-time.

2. Dynamically allocate the output file since its record length depends on the input data. regarding this issue I saw some responds in the forum but not quite understood them.

Is it possible to do such a program?

Many thanks,

Rotem



hai Rotem,

hope these clarificatons help you.

1. For defining the file with no PIC is not possible. But as you suggested you can get the length of record during run time by using OCCURS DEPENDING ON clause.

2. For the output file, you can use variables to identify the length of each input files and accordingly you can allocate the output file.


corrections welcomed...

gowtham
Back to top
View user's profile Send private message
minino

New User


Joined: 15 Nov 2005
Posts: 5

PostPosted: Wed Jan 18, 2006 11:48 pm
Reply with quote

First of all, thank you for your response.

Can you be more specific?

Maybe you have some examples.

Thanks.
Back to top
View user's profile Send private message
gowtham_1982
Warnings : 1

Active User


Joined: 02 Dec 2005
Posts: 109

PostPosted: Thu Jan 19, 2006 12:58 pm
Reply with quote

minino wrote:
First of all, thank you for your response.

Can you be more specific?

Maybe you have some examples.

Thanks.



hai Rotem,

These are my replies on the assumption that you are unaware of the size of both input and output files at the compilation time and you are getting a record of the input file processing it and storing the record in output file.

1. for defining the file with OCCURS DEPENDING ON CLAUSE:

01 emp-rec occurs 5 to 50 times depending on emp-rec-occurence.

05 emp-name ..........
05 emp-no..........

now at run time you will get the value of emp-rec-occurence. based on it the emp-rec will have that many occurences.

2. once you have got to know the size of input file, you can know the size of output file too. please note that it is not possible to define a identifier in COBOL without PIC. So what i feel again is to go for OCCURS DEPENDING ON CLAUSE and store the output in the file.


corrections welcomed.

gowtham
Back to top
View user's profile Send private message
minino

New User


Joined: 15 Nov 2005
Posts: 5

PostPosted: Thu Jan 19, 2006 3:33 pm
Reply with quote

Gowtham hi,

I have tried your solution and i realize it does not work on "fixed length" records only on "variable length", and my files have fixed length record (sorry, forgot to mention it).

Is there any solution for that?

I cannot use the variable legth, since I am receiving the files as fixed length and I cannot ask everybody to change their files for my program.

Thanks for your prompt reply.
Back to top
View user's profile Send private message
gowtham_1982
Warnings : 1

Active User


Joined: 02 Dec 2005
Posts: 109

PostPosted: Fri Jan 20, 2006 10:22 am
Reply with quote

minino wrote:
Gowtham hi,

I have tried your solution and i realize it does not work on "fixed length" records only on "variable length", and my files have fixed length record (sorry, forgot to mention it).

Is there any solution for that?

I cannot use the variable legth, since I am receiving the files as fixed length and I cannot ask everybody to change their files for my program.

Thanks for your prompt reply.



hai Rotem,
as for as i've know the technique of using the OCCURS DEPENDING ON CLAUSE is the only way to get a record while you are unaware of the record lenght at compile time..

i think you can get advise of moderators or super moderators.

kind regards,

gowtham
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top