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
 

 

Doubt in dynamic call.

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

New User


Joined: 14 Mar 2008
Posts: 74
Location: India,Chennai

PostPosted: Thu Dec 02, 2010 8:22 pm    Post subject: Doubt in dynamic call.
Reply with quote

Hi,

I have a doubt in calling a program dynamically. I have an program (prog A) calling a sub program(Prog B). The program B (sub pgm) uses a file(File F1) to do its processing. Program A is calling program B dynamically. My doubt is should i open the file (in sub pgm) every time i call program B (sub pgm), or is it fine if i open the file once in Initial para in Program A (Main pgm).

Can anyone please help me in this.

Thanks in advance,
Sujesh.
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Dec 02, 2010 8:36 pm    Post subject: Reply to: Doubt in dynamic call.
Reply with quote

No, absolutely not. Open it ONCE in the Caller and access it in the Calling program. When you're done, close it in the Caller.

Try defining the file as EXTERNAL in both programs and see if this helps with your dilemma (requires VS/COBOL II and greater) as well as review the applicable IBM COBOL manual.

What have you tried?

Bill
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Dec 02, 2010 8:38 pm    Post subject:
Reply with quote

Not a programmer, so I could be way off of the mark here ......... but

Surely if you open the file every time, and my understanding is that the file is opened at the first record, your output from the program may not be very accurate.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Dec 02, 2010 9:14 pm    Post subject:
Reply with quote

unless you issue a CANCEL Prog B
in Prog A
and
Prog B does not have the INITIAL clause in the program ID paragraph,

you OPEN the file in Program B on the first CALL from A
(yeah, need to save a switch in Progr B)
read the file in program B
and then a final call from A to B to close it.

or,
use the external clause

but you can do allllllll your file handling in program B without any problem.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Thu Dec 02, 2010 10:29 pm    Post subject:
Reply with quote

dbzTHEdinosauer wrote:
unless you issue a CANCEL Prog B
in Prog A
and
Prog B does not have the INITIAL clause in the program ID paragraph,

you OPEN the file in Program B on the first CALL from A
(yeah, need to save a switch in Progr B)
read the file in program B
and then a final call from A to B to close it.

or,
use the external clause

but you can do allllllll your file handling in program B without any problem.

If you want to have program A control all file handling you should implement a function code in your call parameters to B with (at least) 3 values:
    One for open file, and possibly other initialisation
    One for processing
    One for closing file and other cleanup

You can also do with opening the file at first call, and set a switch to mark that the file has been opened. Closing the file can then be left to the operating system when program A ends, though that is generally not considered good practice.
Back to top
View user's profile Send private message
passion_sujesh

New User


Joined: 14 Mar 2008
Posts: 74
Location: India,Chennai

PostPosted: Fri Dec 03, 2010 1:06 am    Post subject: Reply to: Doubt in dynamic call.
Reply with quote

Thanks for ur reply,

I will use the method provided by 'Kjeld'. Can i use the same approach for both statically and dynamically called programs?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Fri Dec 03, 2010 1:18 am    Post subject:
Reply with quote

Quote:
Can i use the same approach for both statically and dynamically called programs?
What, exactly, do you mean by "statically and dynamically called"? The main difference between them is when does the program get loaded -- as part of the compile / linkage edit (bind) process, or when the calling program is executing. It certainly does not sound like this is what you mean, though.
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 REXX - Dynamic file Creation d_sarlie CLIST & REXX 7 Tue Jun 27, 2017 7:30 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Need help in REXX CALL program Raje1002 CLIST & REXX 5 Wed Apr 19, 2017 11:18 pm
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm
No new posts Need help in triggering a PL1 module ... Varungv99 IMS DB/DC 0 Fri Apr 07, 2017 10:01 am


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