Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Dynamic Definition of a data record in the file section

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Dynamic Definition of a data record in the file section
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    Post subject: Re: Dynamic Definition of a data record in the file section
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    Post subject: Re: Dynamic Definition of a data record in the file section
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    Post subject: Re: Dynamic Definition of a data record in the file section
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Sorting group data rajella DFSORT/ICETOOL 3 Sun Jan 22, 2017 11:32 pm
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts how to recover an uncataloged VSAM da... archanamuthukrishnan All Other Mainframe Topics 3 Wed Jan 11, 2017 6:18 pm
No new posts HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 1 Mon Jan 02, 2017 11:16 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us