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
 

 

how to use a file in called program?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Prasanna Srinivas D

New User


Joined: 12 Oct 2007
Posts: 9
Location: chennai

PostPosted: Sat Oct 27, 2007 2:05 pm    Post subject: how to use a file in called program?
Reply with quote

hi,

I have to open a file in the main program which calls other program modules. The modules also use the file (read and write). The main program is also responsible for closing the file.

1> Is write possible in the module program if i pass the buffer descrtiptor to the module from the main program?

eg. file section.
fd file1
01 fs-buffer
.....
.....
procedure division.
call module1 using fs-buffer

2> How is read possible in the module program? since read uses the file name itself, is there any way to pass the file name to the module
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Sat Oct 27, 2007 4:20 pm    Post subject:
Reply with quote

no, cobol is rather explicit about which module can perform i/O. Which ever module contains the FD, that module, and only that module, can execute i/o against the FD.

Suggest that you remove the FD from the main module, write a new module (an i/o module) that can be called from anyone to perform the i/O functions. The way you have it set-up, a submodule must return to the main module to get the next or write/rewrite and then immediately be called again by the main-module. That means a lot of decision making in the main as well as the sub-module.

removing i/o to a sub-module allows a programmer to design a flexible run-unit. any module needing another record or wanting to update the file can perform an 'in-line call' to the i/o module.

In addition, if the data was formerly in a qsam file, it could be changed very easily to a vsam or db2 by only having to modify 1 i/o module.
Back to top
View user's profile Send private message
Prasanna Srinivas D

New User


Joined: 12 Oct 2007
Posts: 9
Location: chennai

PostPosted: Sat Oct 27, 2007 4:31 pm    Post subject: Reply to: how to use a file in called program?
Reply with quote

thank you for the technique... this is much better...
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
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Could we identify the called modules ... elixir1986 COBOL Programming 5 Fri Jul 14, 2017 1:53 am
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm


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