View previous topic :: View next topic
|
Author |
Message |
Ganesh Kalam Warnings : 1 New User
Joined: 11 Aug 2005 Posts: 45 Location: India
|
|
|
|
Hi,
I have a cobol program which calls around 20 subroutines internally.
Each subroutine has some ims calls to read the data from ims database.
I have to remove all the calls and read the data from flat files.
To accomplish this, is it possible to define file operations in subroutines.
Thank you |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Yes, it is possible to define file operations in subroutines. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If you called modules are going to be invoked more than once per run, you will have to consider open and close of the files read in the called modules. |
|
Back to top |
|
|
Ganesh Kalam Warnings : 1 New User
Joined: 11 Aug 2005 Posts: 45 Location: India
|
|
|
|
Shall we pass the file name as parameter to the subroutine. What ever file we are using in the subroutine, should we declare the same in the main program.
Can you please explain how you achieve this. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Only one definition per program, you must realize that those definitions are actually data holders for the status and condition of the open file, you can't have two opened at the same time. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Before you start coding, i'd suggest thinking through what you need to do and how you will accomplish it.
When the "main" program calls a sub-program, it will have to at least provide the "key" to read in the sub-program (unless the whole file will be read each time the sub-program is called - much overhead). The main program may also need to tell the sub-program if this is the first call, a "read" call or and "end" call to properly handle open/close.
Is there some reason that these must be flat files? Is there some way to coordinate between the modules as to where the called module should "start" and "end" for each call? How many records will there be in these converted files?
If you post a more detailed description of your requirement (including what a few of the "ims going flat" files are, we will be able to offer better suggestions. |
|
Back to top |
|
|
Ganesh Kalam Warnings : 1 New User
Joined: 11 Aug 2005 Posts: 45 Location: India
|
|
|
|
The reason for using flat files instead of relational database is just to reduce performance issues and time. But this is a temporary solution.
These files may consists of atleast 10000 records.
Bill, "Only one definition per program" .. I could not get you. Do you mean to say that we can use only one file in the sub-program. Cant we declare two or more files.
Dick, till now these sub-programs are there to handle IMS Database segments. So the main program is passing the PCBs as parameters.
The requirement is , Some of the IMS databases will be removed. So we have to take the corresponding data from flat files and the remaining data from existing IMS databases.
So my sub-program should be able to handle both IMS calls as well as file operations.
What should i do in this scenario ? Can i declare the file in the main program, pass it as parameter to subprogram along with PCBs. (or) Can i declare the files in the sub-program alone without taking them from main program ( i doubt this solution )
Can i use all file operations (open,read,write,close) in the same sub-program.
Can you suggest , whatever i am doing to replace IMS Databases is a better solution keeping the performance and time constraints in mind.
Can you advice if you have any other better solution.
If this information is not sufficient or if you need more details ..please let me know..
Thanks in advance |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Quote: |
Bill, "Only one definition per program" .. I could not get you. Do you mean to say that we can use only one file in the sub-program. Cant we declare two or more files. |
Sorry it got turned around, unless you can guarantee that only one instance of a flat file will be opened at a time, only one program per definition.....
First, flat files can be keyed, KSDS (not really flat but part of the installed base) and ESDS (AIX turns these into "KSDS") can "emulate" the general nature of the IMS you are "migrating" from.
Each subroutine has a expected input upon call and an expected deliverable upon return. Just try to adhere to the existing conventions of the call and (as transparently as possible) the return of the expected data.
Analyze the whole picture and it should be possible to "quietly" replace the subroutines one at a time with very little disruption to the calling program. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Yes, you can use open/close/read/write in sub-programs, but if they will be called multiple times, you must consider when to open/close them.
Well, if you have 10000 records in a flat file and the record you want are at 5000, that is a lot of overhead - especially if the main program called this one sub-program thousands of times.
Just thinking out loud, would not keyed vsam files let you access what you want directly? |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Ganesh,
You may want to take a look at the EXTERNAL feature of COBOL. It looks like it's designed to do the kinds of things you need to do. |
|
Back to top |
|
|
Ganesh Kalam Warnings : 1 New User
Joined: 11 Aug 2005 Posts: 45 Location: India
|
|
|
|
Jack,
I will check whether EXTERNAL clause will be helpful in this situation.
Dick/Bill,
My input file consists of different record types. I cannot consider one particular field as key. I think we cannot use VSAM files in this situation.
Please let me know your thoughts on this
Thanks and Regards |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Different record types sounds like a common variable length situation - or even fixed length with different "types".
How are they accessed in IMS?
I guess i'm confused on just what the called modules do when called. If you will describe one of the typical processes from the calling code perspective and what the called code does with IMS, we may be better able to offer suggestions. If you post functional pseudo-code we should be able to better understand the requirement.
Does each call cause a whole file to be processed? Is each called program a process that could stand alone or does the caller provide information that controls the processing of the called module? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Ganesh Kalam wrote: |
My input file consists of different record types. I cannot consider one particular field as key. I think we cannot use VSAM files in this situation. |
Ganesh Kalam wrote: |
I have a cobol program which calls around 20 subroutines internally.
Each subroutine has some ims calls to read the data from ims database. |
Please explain how even one of those 20 subroutines that have "some ims calls to read the data from ims database" cannot be considered some sort of "key" access?
You say you have called modules that, upon request, provide data. Take them one at a time and replace them. If keyed access would work better than sequential scan for a subroutine, then use it. If sequential scan would be better than keyed access, then use it.
Why do you ask for help and, either not provide enough information to provide it, or just ignore it? |
|
Back to top |
|
|
|