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
 

 

Can we use file operations in a cobol subroutine

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Ganesh Kalam
Warnings : 1

New User


Joined: 11 Aug 2005
Posts: 45
Location: India

PostPosted: Thu Mar 29, 2007 11:27 am    Post subject: Can we use file operations in a cobol subroutine
Reply with quote

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
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Mar 29, 2007 12:53 pm    Post subject:
Reply with quote

Yes, it is possible to define file operations in subroutines.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Mar 30, 2007 12:12 am    Post subject:
Reply with quote

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
View user's profile Send private message
Ganesh Kalam
Warnings : 1

New User


Joined: 11 Aug 2005
Posts: 45
Location: India

PostPosted: Fri Mar 30, 2007 10:30 pm    Post subject: Re: Can we use file operations in a cobol subroutine
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Mar 30, 2007 10:43 pm    Post subject:
Reply with quote

icon_confused.gif 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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Mar 31, 2007 1:34 am    Post subject:
Reply with quote

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
View user's profile Send private message
Ganesh Kalam
Warnings : 1

New User


Joined: 11 Aug 2005
Posts: 45
Location: India

PostPosted: Sat Mar 31, 2007 2:42 am    Post subject: Re: Can we use file operations in a cobol subroutine
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Mar 31, 2007 2:56 am    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Mar 31, 2007 3:22 am    Post subject:
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Apr 01, 2007 6:48 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Ganesh Kalam
Warnings : 1

New User


Joined: 11 Aug 2005
Posts: 45
Location: India

PostPosted: Mon Apr 02, 2007 3:31 am    Post subject: Re: Can we use file operations in a cobol subroutine
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Apr 02, 2007 4:18 am    Post subject:
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Apr 02, 2007 4:27 am    Post subject: Re: Can we use file operations in a cobol subroutine
Reply with quote

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
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 Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 4 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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