View previous topic :: View next topic
|
Author |
Message |
minino
New User
Joined: 15 Nov 2005 Posts: 5
|
|
|
|
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 |
|
|
gowtham_1982 Warnings : 1 Active User
Joined: 02 Dec 2005 Posts: 109
|
|
|
|
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 |
|
|
minino
New User
Joined: 15 Nov 2005 Posts: 5
|
|
|
|
First of all, thank you for your response.
Can you be more specific?
Maybe you have some examples.
Thanks. |
|
Back to top |
|
|
gowtham_1982 Warnings : 1 Active User
Joined: 02 Dec 2005 Posts: 109
|
|
|
|
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 |
|
|
minino
New User
Joined: 15 Nov 2005 Posts: 5
|
|
|
|
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 |
|
|
gowtham_1982 Warnings : 1 Active User
Joined: 02 Dec 2005 Posts: 109
|
|
|
|
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 |
|
|
|